跳到主要内容

SetName

设置当前样式的名称。

语法

expression.SetName(sStyleName);

expression - 表示 ApiStyle 类的变量。

参数

名称必需/可选数据类型默认值描述
sStyleName必需string将用于当前样式的名称。

返回值

boolean

示例

此示例设置当前样式的名称。

// Rename the table style.

// How to change the name of the created table style.

let doc = Api.GetDocument();
let tableStyle = doc.GetStyle("Bordered");
tableStyle.SetName("My Custom Style");
let table = Api.CreateTable(2, 2);
table.SetWidth("percent", 100);
table.SetStyle(tableStyle);
doc.Push(table);
let tableStyleName = tableStyle.GetName();
let paragraph = doc.GetElement(0);
paragraph.AddText("Table style name = " + tableStyleName);