跳到主要内容

GetStyle

按名称返回样式。

语法

expression.GetStyle(sStyleName);

expression - 表示 ApiDocument 类的变量。

参数

名称必需/可选数据类型默认值描述
sStyleName必需string样式名称。

返回值

ApiStyle

示例

此示例展示如何按名称获取样式。

// How to get the style of the heading.

// Display the style name of the "Heading 6".

let doc = Api.GetDocument();
let noSpacingStyle = doc.GetStyle("Heading 6");
let paragraph = doc.GetElement(0);
paragraph.SetStyle(noSpacingStyle);
paragraph.AddText("This is a text in a paragraph styled with the 'Heading 6' style.");