跳到主要内容

GetName

返回指定字体的名称属性。

语法

expression.GetName();

expression - 表示 ApiFont 类的变量。

参数

此方法没有任何参数。

返回值

string | null

示例

获取电子表格中指定字体的字体名称属性。

// How to determine a font name in a spreadsheet.

// Apply a font to the characters then get its name and add it in the range in a spreadsheet.

let worksheet = Api.GetActiveSheet();
let range = worksheet.GetRange("B1");
range.SetValue("This is just a sample text.");
let characters = range.GetCharacters(9, 4);
let font = characters.GetFont();
font.SetName("Font 1");
let fontName = font.GetName();
worksheet.GetRange("B3").SetValue("Font name: " + fontName);