While working with multi-column reports, sometimes you need to display multiple groups or chunks of data in separate columns.
JasperReports provides full flexibility of organizing your data in multiple columns. It also provides a number of tools to introduce a column break into your report according to your needs. The requirement is sometimes static, which can be met by using a page break component, while sometimes it has to be decided at runtime.
In this recipe, the JasperReports engine will dynamically decide the location of a column break. The report engine will look for the change of a customer name and as it finds the change, it inserts a column break, thus separating data of one customer from another's.
Refer to the installPostgreSQL.txt
file included in the source code download of this chapter to install and run PostgreSQL, which should be up and running before you proceed. The source code of this chapter also includes a file named copySampleDataIntoPGS.txt
, which helps you create a database named jasperdb7
and copy sample data for this recipe into the database.
GroupInGroupMultiColumns.jrxml
file from the Task2
folder of the source code of this chapter. The Designer tab of iReport shows a report containing data in the Title, Customer Group Header 1, Product Group Header 1, and Detail 1 sections. A vertical bar is also appearing in the report, which is dividing the Column Header, Customer Group Header 1, Product Group Header 1, Detail 1, Customer Group Footer 1, Product Group Footer 1, and Column Footer sections into two equal halves, as shown in the following screenshot:18.224.30.19