Product comparison table
Generate product comparison
- Template type document docx medium
- Carbone min. v4.24.0+
- Features bidirectional-loop placeholder
- Target product comparator insurance technology custom
Objectives
You want to generate product comparison tables with the following features:
- Repeat the table header when a page breaks
- Use placeholders to dynamically insert images (e.g., logos)
- Use a horizontal loop to compare a variable number of products or companies
Solution
Here’s how you can achieve this using Carbone:
Insert a table and define the elements to be displayed
For example:
A placeholder with the following formula to display the logo:
{d.datas[0].benchmark[i].logo}
The name of the product:
{d.datas[0].benchmark[i].product}
Define the Horizontal Repetition
In the cell immediately to the right, define the horizontal iteration to display all other columns:
{d.datas[0].benchmark[i+1]}
There is no need to duplicate the entire cell; only one tag including
[i+1]
is required.
Define the Vertical Repetition
In the following rows, define the vertical iteration to display the relevant features from your data:
{d.datas[i].features[i].name}
{d.datas[i].features[i+1]}
And there you go!
Tips
Repeat Table Header on Page Break
Highlight the first row of your table, right-click, and select "Table Properties". Go to the "Row" tab and check the option: "Repeat as header row at the top of each page."
Uncheck "Allow Row to Break Across Pages"
Highlight the entire table, right-click, and select "Table Properties". Navigate to the "Row" tab and uncheck the option: "Allow row to break across pages" if you want to prevent cells from splitting across two pages.
Perfect!