Get Started
Usage API
More information

SetStyle

SetStyle(oStyle)

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

Parameters:

Name Type Description
oStyle ApiStyle

The style of the paragraph to be set.

Returns:

This method doesn't return any data.

Example

Copy code
builder.CreateFile("docx");
oDocument = Api.GetDocument();
oHeading6Style = oDocument.GetStyle("Heading 6");
oParaPr = oHeading6Style.GetParaPr();
oParaPr.SetJc("center");
oParagraph = oDocument.GetElement(0);
oParagraph.SetStyle(oHeading6Style);
oParagraph.AddText("This is a text in a paragraph styled with the 'Heading 6' style.");
builder.SaveFile("docx", "SetStyle.docx");
builder.CloseFile();

Resulting document