跳到主要内容

SetName

Sets a name of the current style.

Syntax

expression.SetName(sStyleName);

expression - A variable that represents a ApiStyle class.

Parameters

NameRequired/OptionalData typeDefaultDescription
sStyleNameRequiredstringThe name which will be used for the current style.

Returns

This method doesn't return any data.

Example

This example sets a name of the current 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);