name:
src/main/js/formulas/logic/IFERROR.ts
-rw-r--r--
788
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 IFERROR extends AbstractFormula {
9 static SELF: IFERROR = new IFERROR();
10 NAME = FormulaName.IFERROR;
11
12 internal(origin: SheetColumnRowKey, ...values: Array<Complex>) {
13 AbstractFormula.checkLength(values.length, 2, this.NAME);
14 const value = this.collateralLookup(origin, values[0]);
15 if (Converters.first(value) instanceof F7Exception) {
16 return this.collateralLookup(origin, values[1]);
17 }
18 return value;
19 }
20}