跳到主要内容

SetStyle

The paragraph style base method. 💡 This method is not used by itself, as it only forms the basis for the {@link ApiParagraph#SetStyle} method which sets the selected or created style for the paragraph.

Syntax

expression.SetStyle(oStyle);

expression - A variable that represents a ApiParagraph class.

Parameters

NameRequired/OptionalData typeDefaultDescription
oStyleRequiredApiStyleThe style of the paragraph to be set.

Returns

This method doesn't return any data.

Example

This example sets a style for the paragraph.

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