TRY NEW VERSION

IF

IF(arg1, arg2, arg3) → { number | string | boolean }

Checks whether a condition is met, and returns one value if TRUE, and another value if FALSE.

Parameters:

Name Type Description
arg1 boolean

Is any value or expression that can be evaluated to TRUE or FALSE.

arg2 any

Is the value that is returned if Logical_test is TRUE. If omitted, TRUE is returned. You can nest up to seven IF functions.

arg3 any

Is the value that is returned if Logical_test is FALSE. If omitted, FALSE is returned.

Returns:

Type
number | string | boolean

Example

Copy code
builder.CreateFile("xlsx");
var oWorksheet = Api.GetActiveSheet();
var oFunction = Api.GetWorksheetFunction();
oWorksheet.GetRange("A1").SetValue(oFunction.IF("12<100", 0, 1));
builder.SaveFile("xlsx", "IF.xlsx");
builder.CloseFile();

Resulting document