SetStyle
Sets the style to 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");
var oDocument = Api.GetDocument();
var oParagraph = oDocument.GetElement(0);
oParagraph.AddText("ONLYOFFICE Document Builder");
var oRange = oDocument.GetRange(0, 26);
var oStyle = oDocument.GetStyle("Heading 2");
oRange.SetStyle(oStyle);
builder.SaveFile("docx", "SetStyle.docx");
builder.CloseFile();
Resulting document