Tables

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 - Simple

Table - Single Column

Table - Total

Table - Span Rows

Table - Merge Cells

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>>

mceclip0.png

This generates the following output:

mceclip1.png

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>>

mceclip2.png

This generates the following output:

mceclip3.png

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:

mceclip5.png

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)]>>

mceclip3.png

This generates the following output:

mceclip4.png

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

mceclip0.png

This generates the following output:

mceclip1.png

Table - Merge Cells

Merge table cells with equal text content using <<cellMerge>> tags. 

By default, a cellMerge tag causes a cell merging operation only in a vertical direction during runtime. However, you can alter this behaviour in the following ways:

  • To merge cells only in a horizontal direction, use the -horz switch as follows:
    <<cellMerge - horz>>
  • To merge cells in both vertical and horizontal directions, use the -both switch as follows:
    <<cellMerge -both>>

Example JSON Data:

{
"Media": [
{
"Genre": "Sci-Fi",
"Titles": [
{
"Movie": "Star Wars: The Phantom Menace",
"Rating": "8/10",
"Platform": "Disney",
"Type": "Movie"
},
{
"Movie": "Star Trek: The Motion Picture",
"Rating": "8/10",
"Platform": "Amazon",
"Type": "Movie"
},
{
"Movie": "Star Wars: The Mandalorian",
"Rating": "9/10",
"Platform": "Disney",
"Type": "TV Series"
}
]
},
{
"Genre": "Fantasy",
"Movies": [
{
"Movie": "The Lord of the Rings: The Rings of Power",
"Rating": "7/10",
"Platform": "Amazon",
"Type": "Tv Series"
},
{
"Movie": "The Magicians",
"Rating": "6/10",
"Platform": "Amazon",
"Type": "Tv Series"
}
]
}
]
}

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 [varMedia in Media]>><<foreach [varTitle in varMedia. Titles]>><<[varMedia. Genre]>> <<cellMerge>>
Row 1 > Column 2: <<[varTitle.Movie]>>
Row 1 > Column 3: <<[varTitle. Rating]>>
Row 1 > Column 4: <<[varTitle. Platform]>>
Row 1 > Column 5: <<[varTitle. Type]>><</foreach>><</foreach>>


This generates the following output:

 

Dynamic Table Background Colors

Please refer to Background Colors / Fill Settings syntax documentation.

Have more questions? Submit a request

0 Comments

Please sign in to leave a comment.
Powered by Zendesk