Get Started
Usage API
More information

ToJSON

ToJSON() → { JSON }

Converts the ApiStyle object into the JSON object.

Parameters:

This method doesn't have any parameters.

Returns:

Type
JSON

Example

Copy code
builder.CreateFile("docx");
var oDocument = Api.GetDocument();
var oTableStyle = oDocument.GetStyle("Bordered - Accent 5");
let json = oStyle.ToJSON(false);
var oStyleFromJSON = Api.FromJSON(json);
oStyleFromJSON.SetName("My Custom Style");
var oTable = Api.CreateTable(2, 2);
oTable.SetWidth("percent", 100);
oTable.SetStyle(oStyleFromJSON);
oDocument.Push(oTable);
builder.SaveFile("docx", "ToJSON.docx");
builder.CloseFile();

Resulting document