跳到主要内容

LEFTB

从指定字符串的左侧字符开始提取子字符串,适用于使用双字节字符集 (DBCS) 的语言,如日语、中文、韩语等。

语法

expression.LEFTB(arg1, arg2);

expression - 表示 ApiWorksheetFunction 类的变量。

参数

名称必需/可选数据类型默认值描述
arg1必需ApiRange | ApiName | string包含要提取字符的文本字符串。
arg2可选ApiRange | ApiName | number基于字节的子字符串字符数。

返回值

string

示例

在电子表格中使用多字节字符的字节计数从字符串左侧提取文本。

// How do I get a substring from text in languages like Chinese or Japanese in a spreadsheet?

// Work with left-aligned text extraction that counts bytes instead of characters in a spreadsheet.

let worksheet = Api.GetActiveSheet();
let func = Api.WorksheetFunction;
worksheet.GetRange("A1").SetValue(func.LEFTB("Online Office", 6));