Get Started
Usage API

SetStyle

SetStyle(oStyle) → { ApiRange | null }

Set the style for the current Range

Parameters:

Name Type Description
oStyle ApiStyle

The style which must be applied to the text character.

Returns:

Type
ApiRange | null

Example

Copy code
builder.CreateFile("docx");
oDocument = Api.GetDocument();
oParagraph = oDocument.GetElement(0);
oParagraph.AddText("ONLYOFFICE Document Builder");
oRange = oDocument.GetRange(0, 26);
oStyle = oDocument.GetStyle("Heading 2");
oRange.SetStyle(oStyle);
builder.SaveFile("docx", "SetStyle.docx");
builder.CloseFile();

Resulting document