f7
f7 is a spreadsheet formula execution library
git clone https://git.vogt.world/f7.git
Log | Files | README.md | LICENSE.md
← All files
name: src/main/js/formulas/text/CONCAT.ts
-rw-r--r--
948
 1import { F7Exception } from "../../errors/F7Exception";
 2import { SheetColumnRowKey } from "../../models/common/SheetColumnRowKey";
 3import { Complex } from "../../models/common/Types";
 4import { Converters } from "../../utils/Converters";
 5import { AbstractFormula } from "../AbstractFormula";
 6import { FormulaName } from "../FormulaName";
 7
 8export class CONCAT extends AbstractFormula {
 9  static SELF: CONCAT = new CONCAT();
10  NAME = FormulaName.CONCAT;
11
12  internal(origin: SheetColumnRowKey, ...values: Array<Complex>) {
13    AbstractFormula.checkLength(values.length, 2, this.NAME);
14    const first = Converters.first(this.collateralLookup(origin, values[0]));
15    const second = Converters.first(this.collateralLookup(origin, values[1]));
16    if (first instanceof F7Exception) {
17      return first;
18    }
19    if (second instanceof F7Exception) {
20      return second;
21    }
22    return `${Converters.toText(first)}${Converters.toText(second)}`;
23  }
24}