Subreports

One nice feature of JasperReports is that it allows incorporating a report within another report. That is, one report can be a subreport of another. Subreports allow us to keep report designs simple, as we can create many simple reports and encapsulate them into a master report.

Let's create a more detailed version of the report discussed in the previous section. This new version divides the reported aircraft into the city to which they are registered. We will create one report that displays the aircraft registered in each city for a particular state. Then, we'll use that report as a subreport for a master report that divides the aircraft by state. The JRXML template for the subreport is as follows:

<?xml version="1.0" encoding="UTF-8" ...

Get JasperReports 3.5 for Java Developers now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.