Skip to content

Commit

Permalink
feature: ApiTableRowPr.ToJSON
Browse files Browse the repository at this point in the history
  • Loading branch information
Yar04ek committed Nov 28, 2023
1 parent 01f7b62 commit 77b0037
Showing 1 changed file with 13 additions and 22 deletions.
35 changes: 13 additions & 22 deletions js/docx/smoke/api_table_row_pr/to_json.js
Original file line number Diff line number Diff line change
@@ -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();



0 comments on commit 77b0037

Please sign in to comment.