跳到主要内容

CODE

返回计算机字符集中指定文本字符串第一个字符的代码数字。

语法

expression.CODE(arg1);

expression - 表示 ApiWorksheetFunction 类的变量。

参数

名称必需/可选数据类型默认值描述
arg1必需ApiRange | ApiName | string要获取其第一个字符代码的文本。

返回值

number

示例

获取电子表格中文本字符串第一个字符的数字代码值。

// Retrieve the character set number that identifies the first letter of a word in a spreadsheet.

// Convert the first character of your text into its underlying numeric representation in a spreadsheet.

let worksheet = Api.GetActiveSheet();
let func = Api.WorksheetFunction;
worksheet.GetRange("A1").SetValue(func.CODE("office"));