The Encodian population engine enables JSON data to be easily added to tables within your word document.
This article provides detailed examples for creating the following types of tables:
Table - Dynamic Background Colors
Table - Simple
Example Document: Encodian - Template Syntax - Table Simple.docx
Example JSON Data:
{
"companyName": "Encodian",
"contracts": [
{
"customerName": "Microsoft",
"value": 100000,
"expires": "13/06/2021"
},
{
"customerName": "Encodian",
"value": 6872500,
"expires": "18/02/2029"
},
{
"customerName": "Heritage",
"value": 13549,
"expires": "6/12/2025"
}
]
}
Configure the table within your word document and then populate it as follows to add the relevant JSON properties to each column:
Column 1: <<foreach [contract in contracts]>><<[contract.customerName]>>
Column 2: <<[contract.expires]:"yyyy.MM.dd">>
Column 3: <<[contract.value]>><</foreach>>
This generates the following output:
Table - Single Column
Example Document: Encodian - Template Syntax - Table Single Column.docx
Example JSON Data:
{
"companyName": "Encodian",
"contracts": [
{
"customerName": "Microsoft",
"value": 100000,
"expires": "13/06/2021"
},
{
"customerName": "Encodian",
"value": 6872500,
"expires": "18/02/2029"
},
{
"customerName": "Heritage",
"value": 13549,
"expires": "6/12/2025"
}
]
}
Configure the table within your word document and then populate it as follows to add the relevant JSON properties to each column:
Row 1 > Column 1: <<foreach [contract in contracts]>>Customer: <<[contract.customerName]>>, Contract Date:<<[contract.expires]:"yyyy.MM.dd">>, Value: £<<[contract.value]>><</foreach -greedy>>
This generates the following output:
NOTE: the -greedy switch instructs the population engine to treat the property as a single row, if this is not used the output would be as follows:
Table - Total
Example Document: Encodian - Template Syntax - Table Totals.docx
Example JSON Data:
{
"companyName": "Encodian",
"contracts": [
{
"customerName": "Microsoft",
"value": 100000,
"expires": "13/06/2021"
},
{
"customerName": "Encodian",
"value": 6872500,
"expires": "18/02/2029"
},
{
"customerName": "Heritage",
"value": 13549,
"expires": "6/12/2025"
}
]
}
Configure the table within your word document and then populate it as follows to add the relevant JSON properties to each column:
Row 1 > Column 1: <<foreach [contract in contracts]>><<[contract.customerName]>>
Row 1 > Column 2: <<[contract.expires]:"yyyy.MM.dd">>
Row 1 > Column 3: £<<[contract.value]>><</foreach>>
Row 2 - Column 1: £<<[contracts.Sum(c =>c.value)]>>
This generates the following output:
Table - Span Rows
Example Document: Encodian - Template Syntax - Table Span Rows.docx
Example JSON Data:
{
"companyName": "Encodian",
"contracts": [
{
"customerName": "Microsoft",
"value": 100000,
"expires": "13/06/2021"
},
{
"customerName": "Encodian",
"value": 6872500,
"expires": "18/02/2029"
},
{
"customerName": "Heritage",
"value": 13549,
"expires": "6/12/2025"
}
]
}
Configure the table within your word document and then populate as follows to add the relevant JSON properties to each column:
Row 1 > Column 1: <<foreach [contract in contracts]>><<[contract.customerName]>>
Row 1 > Column 2: <<[contract.expires]:"yyyy.MM.dd">>
Row 2 > Column 1: £Value: £<<[contract.value]>>
Row 2 > Column 2: <</foreach -greedy>>
NOTE: the -greedy switch instructs the population engine to treat the property as a single row
This generates the following output:
Table - Merge Cells
Merge table cells with equal text content using the <<cellMerge>> tag.
By default, a 'cellMerge' tag performs a vertical merge operation. However, you can control this behaviour using the following two options
To perform a horizontal merge, use the -horz switch:
<<cellMerge -horz>>
To perform both a vertical and horizontal merge, use the -both switch:
<<cellMerge -both>>
Example Document: Encodian - Template Syntax - Table Merge.docx
Example JSON Data:
{
"Movies": [
{
"Genre": "Sci-Fi",
"Titles": [
{
"Title": "Star Wars: The Phantom Menace",
"Rating": "8",
"Platform": "Disney",
"Type": "Movie"
},
{
"Title": "Star Trek: The Motion Picture",
"Rating": "8",
"Platform": "Amazon",
"Type": "Movie"
},
{
"Title": "Star Wars: The Mandalorian",
"Rating": "10",
"Platform": "Disney",
"Type": "TV Series"
}
]
},
{
"Genre": "Fantasy",
"Titles": [
{
"Title": "Lord of the Rings: The Rings of Power",
"Rating": "8",
"Platform": "Amazon",
"Type": "Movie"
},
{
"Title": "The Magicians",
"Rating": "6",
"Platform": "Amazon",
"Type": "TV Series"
}
]
}
]
}
Configure the table within your Word documents and then populate as follows to add the relevant JSON properties to each column:
Column 1: <<foreach [movie in Movies]>><<foreach [title in movie.Titles]>><<[movie.Genre]>><<cellMerge>>
Column 2: <<[title.Title]>>
Column 3: <<[title.Rating]>>
Column 4: <<[title.Platform]>>
Column 5: <<[title.Type]>><</foreach>><</foreach>>
This generates the following output:
Dynamic Table Background Colors
Please refer to Background Colors / Fill Settings syntax documentation.
0 Comments