-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
70 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
builder.CreateFile("docx"); | ||
// oParagraph | ||
var oDocument = Api.GetDocument(); | ||
var oParagraph = Api.CreateParagraph(); | ||
oParagraph.AddText("paragraph"); | ||
oDocument.Push(oParagraph); | ||
|
||
// oTable | ||
var oTableStyle = oDocument.CreateStyle("CustomTableStyle", "table"); | ||
oTableStyle.SetBasedOn(oDocument.GetStyle("Bordered")); | ||
var oTable = Api.CreateTable(3, 3); | ||
oTable.SetWidth("percent", 100); | ||
oTable.SetTableDescription("Empty table"); | ||
oTable.SetStyle(oTableStyle); | ||
var oCell = oTable.GetCell(0, 0); | ||
oCell.GetContent().GetElement(0).AddText(oTable.GetClassType()); | ||
oDocument.Push(oTable); | ||
|
||
// oBlockLvlSdt | ||
var oBlockLvlSdt = Api.CreateBlockLvlSdt(); | ||
oBlockLvlSdt.GetContent().GetElement(0).AddText(oBlockLvlSdt.GetClassType()); | ||
oParagraph = Api.CreateParagraph(); | ||
oParagraph.AddText("This is a block text content control."); | ||
oBlockLvlSdt.Push(oParagraph); | ||
oDocument.Push(oBlockLvlSdt) | ||
|
||
var bWriteDefaultTextPr = false | ||
// Specifies if the default text properties will be written to the JSON object or not. | ||
var bWriteDefaultParaPr = false | ||
// Specifies if the default paragraph properties will be written to the JSON object or not. | ||
var bWriteTheme = false | ||
// Specifies if the document theme will be written to the JSON object or not. | ||
var bWriteSectionPr = false | ||
// Specifies if the document section properties will be written to the JSON object or not. | ||
var bWriteNumberings = false | ||
// Specifies if the document numberings will be written to the JSON object or not. | ||
var bWriteStyles = false | ||
// Specifies if the document styles will be written to the JSON object or not. | ||
|
||
var json = oDocument.ToJSON(bWriteDefaultTextPr, | ||
bWriteDefaultParaPr, | ||
bWriteTheme, | ||
bWriteSectionPr, | ||
bWriteNumberings, | ||
bWriteStyles); | ||
|
||
GlobalVariable["JSON"] = json; | ||
builder.CloseFile(); | ||
|
||
//////////////////////// | ||
|
||
builder.CreateFile("docx"); | ||
var json = GlobalVariable["JSON"]; | ||
var oDocumentFromJSON = Api.FromJSON(json); | ||
var oDocument = Api.GetDocument(); | ||
oDocument.GetElement(0).AddText(json); | ||
oDocument.Push(oDocumentFromJSON[1]); | ||
oDocument.Push(oDocumentFromJSON[2]); | ||
oDocument.Push(oDocumentFromJSON[4]); | ||
builder.SaveFile("docx", "DocumentToJSON.docx"); | ||
builder.CloseFile(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters