跳到主要内容

CONVERT

将数字从一个度量系统转换为另一个度量系统。

语法

expression.CONVERT(arg1, arg2, arg3);

expression - 表示 ApiWorksheetFunction 类的变量。

参数

名称必需/可选数据类型默认值描述
arg1必需ApiRange | ApiName | number要转换的指定单位的值。
arg2必需ApiRange | ApiName | string原始度量单位。
arg3必需ApiRange | ApiName | string结果的单位。

返回值

number

示例

此示例演示如何将数字从一种度量系统转换为另一种度量系统。

// How to convert a number from one measurement system to another.

// Use function to convert a number from one measurement system to another.

let worksheet = Api.GetActiveSheet();
let func = Api.WorksheetFunction;
worksheet.GetRange("A1").SetValue(func.CONVERT(2, "Ibm", "kg"));