跳到主要内容

ToJSON

将 ApiTableStylePr 对象转换为 JSON 对象。

语法

expression.ToJSON();

expression - 表示 ApiTableStylePr 类的变量。

参数

此方法没有任何参数。

返回值

JSON

示例

将条件表格样式设置导出为文档中的可移植数据对象。

// How do I save the table style properties in a transferable format in a document?

// Serialize the table style configuration for later reuse or inspection in a document.

let doc = Api.GetDocument();
let tableStyle = doc.CreateStyle("CustomTableStyle", "table");
tableStyle.SetBasedOn(doc.GetStyle("Bordered"));
let table = Api.CreateTable(3, 3);
table.SetWidth("percent", 100);
let tableStylePr = tableStyle.GetConditionalTableStyle();
table.SetStyle(tableStyle);
doc.Push(table);
let json = tableStylePr.ToJSON();
let tableStylePrFromJSON = Api.FromJSON(json);
let type = tableStylePrFromJSON.GetClassType();
let paragraph = doc.GetElement(0);
paragraph.AddText("Class type = " + type);