跳到主要内容

ISERROR

检查值是否为错误,并返回 truefalse

语法

expression.ISERROR(arg1);

expression - 表示 ApiWorksheetFunction 类的变量。

参数

名称必需/可选数据类型默认值描述
arg1必需number | string | boolean | ApiRange | ApiName要测试的值。值可以是空单元格、错误、逻辑值、文本、数字、区域或区域名称。

返回值

boolean

示例

此示例演示如何检查值是否为错误,并返回 true 或 false。

// How to check if the cell contains an error.

// Use a function to check whether the value is error or not.

const worksheet = Api.GetActiveSheet();
let func = Api.WorksheetFunction;
worksheet.GetRange("B3").SetValue("#N/A")
let result = func.ISERR("B3");
worksheet.GetRange("C3").SetValue(result)