name:
src/main/js/formulas/logic/IFNA.ts
-rw-r--r--
950
1import { F7Exception } from "../../errors/F7Exception";
2import { F7ExceptionName } from "../../errors/F7ExceptionName";
3import { SheetColumnRowKey } from "../../models/common/SheetColumnRowKey";
4import { Complex } from "../../models/common/Types";
5import { Converters } from "../../utils/Converters";
6import { AbstractFormula } from "../AbstractFormula";
7import { FormulaName } from "../FormulaName";
8
9export class IFNA extends AbstractFormula {
10 static SELF: IFNA = new IFNA();
11 NAME = FormulaName.IFNA;
12
13 internal(origin: SheetColumnRowKey, ...values: Array<Complex>) {
14 AbstractFormula.checkLength(values.length, 2, this.NAME);
15 const value = this.collateralLookup(origin, values[0]);
16 const first = Converters.first(value);
17 if (
18 first instanceof F7Exception &&
19 Converters.castAsF7Exception(first).name === F7ExceptionName.NA
20 ) {
21 return this.collateralLookup(origin, values[1]);
22 }
23 return value;
24 }
25}