Table with dynamic columns

Using tables for printing lists of structured data is convenient and effective for printing invoice items or shipping items.
However, you will not always have a predefined set of table columns but instead need the table columns created dynamically to get it to grow both horizontally and vertically based on given data. In ReportBro this can be achieved by using simple list parameters.

In this tutorial you will learn to:
Set up parameters for dynamic columns
Create a dynamic column table

1 Set up parameters for dynamic columns

Let's take the example of a report on working time of employees. We have a number of employees that spend their time working on different projects. We'd like to get a report that shows how much time each employee spends on which project. Both entities are dynamic as both employees and projects cannot be predefined as fixed values.

First of all we need a parameter of type simple list for the table columns: projects
Because it's a simple list parameter we define the data type the simple list is going to expect - text. Now let's add some projects as test data.

Next we create the parameters for the table rows. Each row entry is composed of an employee name and time values, hence we need a parameter of type list: entries
Inside this list we create parameters for employee name and time:
- employee (text)
- time (simple list)

We use a simple list with data type text again for the time value. The test data popup shows a column for each of the parameters but allows us to add more columns for the simple list parameter time. Let's add the same amount of columns for the simple list as we have defined for the projects and fill some rows of data.

2 Create a dynamic column table

Finally, we are ready to create the table and apply the parameters (if you are new to ReportBro you can find a tutorial on how to add a table here).

The data source has to be the parameter of type list:
entries

By setting our simple list parameter projects in the second header column the table columns will be automatically expanded horizontally to show all items of this parameter.

The content part contains the employee name and the working time spent for each project.

Bro tip: Make sure that your document layout is wide enough to hold all expected columns to be printed. This won't be an issue with XLS but PDF requires predefined page dimensions.

Print it like a Bro

Let's have a look at the result.

ReportBro Screenshot showing activated debug mode

Try it yourself: Download the report of this tutorial
Read here how to import the report into ReportBro Designer.

Want to know more about tables? Read our tutorials for
Creating tables,
Condition-based table column printing and
Table grouping

By the way, ReportBro is also available for everyone as open-source on github (see Download page). Star us on github if you like what you see!