跳到主要内容

ABS

返回数字的绝对值,即不带符号的数字。

语法

expression.ABS(arg1);

expression - 表示 ApiWorksheetFunction 类的变量。

参数

名称必需/可选数据类型默认值描述
arg1必需ApiRange | ApiName | number将返回其绝对值的实数。

返回值

number

示例

查找电子表格中数字的绝对值。

// How do I convert a negative number to positive in a spreadsheet?

// Discard the sign and use only the magnitude of any value in a spreadsheet.

let worksheet = Api.GetActiveSheet();
let func = Api.WorksheetFunction;
worksheet.GetRange("A1").SetValue(func.ABS(-123.14));