Planification

Share your planification with Carbone

Download Template

Download data sample

  • Template type document docx simple
  • Carbone min. v5.0.0+
  • Features loop filter alias aggregator
  • Target planification custom

Objectives

You want to generate a report to showcase your planning with the following features:

  • A table with different widths between the first page and subsequent pages.
  • Automatic deduction of the number of lines to display on the first page, as descriptions have varying lengths.
  • Simplified syntax to create a more readable template.
  • Automatic calculation of the subtotal for the displayed elements on the first page.

Solution

Here’s how you can achieve this using Carbone:

  1. Estimate the number of characters per line

    Create the first table on the first page. Since the length of descriptions varies, they may span multiple lines. To address this, estimate the number of characters that can fit on a single line (e.g., 40), based on your layout settings.

  2. Define the number of lines each description will occupy

    To determine the number of lines each description will take:

  • Divide the length (len) of the description by the estimated number of characters per line (e.g., 40).

  • Round up to the nearest whole number using the ceil formatter.

  • Store the cumulative sum (cumSum) using the set formatter.

    The corresponding formula is as follows:
    {d.steps[].description:len:div(40):ceil:cumSum:set(.nbRow)}

At this stage, each object will have a new property named nbRow, which indicates the number of lines it will occupy based on the characteristics of the first table.

JSON Before

{
  "steps": [
    {
      "step": 1,
      "name": "Choosing the land",
      "duration_days": "30",
      "description": "Identify and visit several plots to assess location, viability, and utility connections. Finalize the purchase once the land is selected."
    },
    {...},
    {
      "step": 6,
      "name": "Foundations",
      "duration_days": "20",
      "description": "Dig trenches, pour the foundations, and set up the base structure."
    },
    {...}
  ]
}

JSON After

{
  "steps": [
    {
      "step": 1,
      "name": "Choosing the land",
      "duration_days": "30",
      "description": "Identify and visit several plots to assess location, viability, and utility connections. Finalize the purchase once the land is selected.",
      "nbRow":4
    },
    {...},
    {
      "step": 6,
      "name": "Foundations",
      "duration_days": "20",
      "description": "Dig trenches, pour the foundations, and set up the base structure.",
      "nbRow":22
    },
    {...}
  ]
}
  1. Define and use aliases

    Using aliases will make the Carbone tags more readable afterward.

    Define one alias to set the filtered data for the first table, and another to set the filtered data for the second table. {#steps =d.steps[i, nbRow < 22]} {#steps2 = d.steps[i, nbRow > 21]}

    Use {$steps.description} and {$steps2.description} respectively in the tables

  1. Compute the subtotal

    To print the subtotal, use the aggSum formatter. You can filter the values to include only the relevant ones. {d.steps[nbRow<22].duration_days:aggSum}

And there you go!

Tips

  • Prevent rows from breaking across pages

    If you don’t want rows to break across pages, follow these steps:

    1. Highlight the table in the template.
    2. Right-click and go to the Table Properties menu.
    3. Navigate to the Row section.
    4. Deselect the option to allow rows to break across pages.
  • Repeat header rows on subsequent pages

    If you want to repeat the first row when your table spans page 3 and beyond, follow these steps:

    1. Highlight the first row of your second table in the template.
    2. Right-click and go to the Table Properties menu.
    3. Navigate to the Row section.
    4. Select the option "Repeat as header row at the top of each page."

Perfect!

You might also like

Trusted by 600+ paid customers in 40+ countries

Finance
Healthcare
Public
Retail
Industries
Energy
Software
Telecom
1dior.png
22thales.png
23younited.png
2danfoss.png
3cma-cgm.png
3illumina.svg
4KparK.png
6scalingo.png
7defense.png
8bmw.png
8telus.png
bestseller.png
flagship_bioscience.png
insly.png
ninox.png
sodexo.png