Bidirectional-loop
Generate product comparison
- Template type document docx simple
- Carbone min. v4.24.0+
- Features bidirectional-loop placeholder
- Target product comparator insurance technology custom
Objectives
Generate a report with the following features:
- Present information in a table
- Use a horizontal loop to display differents catagories of a product
- Compute the sum of all values in a dataset
- Present information in a chart
Solution
Here’s how to construct a template to achieve this with Carbone:
Insert a table and define the elements to be displayed
- Insert the appropriate Carbone tags to read data from your array.
Example:{d.products[i].brand}
and{d.products[i].model}
- Use the iterator
[i+1]
in the row bellow to define the vertical iteration.
Example:{d.products[i+1]}
Note: There is no need to duplicate the entire tag; only one tag including[i+1]
is required.
- Insert the appropriate Carbone tags to read data from your array.
Horizontal repetition
- Insert the appropriate Carbone tag to read data from your array.
Example:{d.allSize[size].size}
- In the cell immediately to the right, define the horizontal iteration to display all other columns.
Example:{d.allSize[size+1].size}
- Do the same for all data you want to display through this horizontal loop.
Example:{d.products[i].size[size].qty}
and{d.products[i].size[size+1].qty}
- Insert the appropriate Carbone tag to read data from your array.
Computation
- Use aggSum formatter to compute the total sum of all values.
Example:{d.products[i].size[].qty:aggSum}
- Use aggSum formatter to compute the total sum of all values.
Chart
- Insert a chart with the expected design
- When Excel automatically pops up, or by right-clicking on the inserted chart and selecting the Edit Data in Excel menu, define the data to display.
Include the values for the series using Carbone tags and iteration. Example:
| | Sales | |-----------------------------------------------------| | {d.allSize[i].size} | {d.allSize[i].totalQty} | | {d.allSize[i+1].size} | {d.allSize[i+1].totalQty} |
- The rendering will be completed during the report generation process.
And there you go!
You might also like
Trusted by 600+ paid customers in 40+ countries
Finance
Healthcare
Public
Retail
Industries
Energy
Software
Telecom














