From 77b0037250b1d4c8e28260c9e76aa527ac92e438 Mon Sep 17 00:00:00 2001 From: Yar04ek Date: Tue, 28 Nov 2023 14:08:58 +0100 Subject: [PATCH] feature: ApiTableRowPr.ToJSON --- js/docx/smoke/api_table_row_pr/to_json.js | 35 +++++++++-------------- 1 file changed, 13 insertions(+), 22 deletions(-) diff --git a/js/docx/smoke/api_table_row_pr/to_json.js b/js/docx/smoke/api_table_row_pr/to_json.js index ab28378f..5374c71f 100644 --- a/js/docx/smoke/api_table_row_pr/to_json.js +++ b/js/docx/smoke/api_table_row_pr/to_json.js @@ -1,38 +1,29 @@ builder.CreateFile("docx"); - let oDocument = Api.GetDocument(); - let oParagraph = oDocument.GetElement(0); - let oTableStyle = oDocument.CreateStyle("CustomTableStyle", "table"); - oTableStyle.SetName("My Custom Table Style"); - let oTableRowPr = oTableStyle.GetTableRowPr(); - oTableRowPr.SetHeight("atLeast", 720); - let jsonTableStyle = oTableStyle.ToJSON(); - GlobalVariable["JSON_TableStyle"] = jsonTableStyle; - oParagraph.AddText(jsonTableStyle); +let oDocument = Api.GetDocument(); +let oParagraph = oDocument.GetElement(0); +let oTableStyle = oDocument.CreateStyle("CustomTableStyle", "table"); +oTableStyle.SetName("My Custom Table Style"); +let oTableRowPr = oTableStyle.GetTableRowPr(); +oTableRowPr.SetHeight("atLeast", 720); +let jsonTableStyle = oTableStyle.ToJSON(); +GlobalVariable["JSON_TableStyle"] = jsonTableStyle; +oParagraph.AddText(jsonTableStyle); builder.CloseFile(); - -///////////////// - +////////////// builder.CreateFile("docx"); let oDocument = Api.GetDocument(); + let oParagraph = oDocument.GetElement(0); let jsonTableStyle = GlobalVariable["JSON_TableStyle"]; oParagraph.AddText(jsonTableStyle); - let oTableStyleFromJSON = Api.FromJSON(jsonTableStyle); - oDocument.Push(oTableStyleFromJSON); - let oParagraph2 = Api.CreateParagraph(); - oDocument.Push(oParagraph2); let oTableStyle = oDocument.GetStyle("My Custom Table Style"); let oTable = Api.CreateTable(3, 3); oTable.SetStyle(oTableStyle); oDocument.Push(oTable); let jsonTable = oTableStyle.ToJSON(); - let oParagraph3 = Api.CreateParagraph(); - oDocument.Push(oParagraph3); - oParagraph3.AddText(jsonTable); + let oParagraph2 = Api.CreateParagraph(); + oDocument.Push(oParagraph2); oParagraph2.AddText(jsonTable); builder.SaveFile("docx", "TableStyleToJSON.docx"); builder.CloseFile(); - - -