Thursday, August 23, 2012

NextReports: Easy way to use subreports

Following previous post "NextReports: Parent and children reports"  it's time to show a simple example of a sub-report usage.

A sub-report is just a simple report with one or more parameters. Let's think about a report which shows a list of employees and the hours they worked for a specific project:

This report has a $P{Project} parameter. When we run it, the value is asked:

and after selection the result is like:

To use this report as a sub-report, we have to create a master report. We use as example a report that selects a list with projects and total hours worked for projects. In one cell we will insert the sub-report, making the layout looking like:

To make our sub-report have the $P{Project} parameter completed for every column $C{Project} NextReports has a simple convention: The column from master report must have an alias with the same name as the parameter from sub-report. In our case both alias column from master and parameter from sub-report have the name Project.

When we run this report we will get a nice PDF. We just use some colors to see what is from master and what is from sub-report.

No comments: