Creating and Adding Reports to the Report Book¶
Now that your framework is established, you can create reports and/or subreports to include in your book.
You create a report or subreport as described here, and in Creating a New Report. You can also include previously created reports. See Adding a Report to the Report Book.
For our walkthrough, you create a report, then add it to your report book.
Creating a Report for the Report Book¶
To create a report
-
Click
and select Other... to open the Wizard selection window. -
Expand the Jaspersoft Studio folder and select Jasper Report. Click Next.
-
In the Report Templates window, scroll to and select the Leaf Green template. Click Next.
-
In the Report file window, select the MyReports folder and change the Leaf_Green.file name to
Content_Page_One.jrxml. Click Next. -
In the Data Source window, select Sample DB – Database JDBC Connection, and enter the following query:
Select * from orders order by shipcity -
Click Next.
-
In the Fields window, move the following Dataset fields to the Fields panel on the right to include them in your subreport:
-
ORDERID
- CUSTOMERID
- FREIGHT
- SHIPCITY
- SHIPCOUNTRY
-
Click Next.
- In the Group By window, move the SHIPCITY dataset field into the Fields pane.
- Click Finish. The Content_Page_One.jrxml appears in the Design tab.
- In the Project Explorer, right-click Content_Page_One.jrxml and select Compile Report. The resulting file, Content_Page_One.jasper, appears in the Project Explorer.
Adding a Report to the Report Book¶
Now you can add this new subreport to your report book. During this process, you assign a data source for running the subreport.
To add a report to your report book
- Double-click the Sample_Book.jrxml in the Project Explorer to open it in the Design tab.
- Drag Content_Page_One.jasper from the Project Explorer into the Content group. In the Connection dialog, click Finish.
- In the Design tab, click to select Content_Page_One.jasper.
- In the Properties view, click the Data button at the top, then click Edit Parameters.
- In the Report Part Parameters window, click Add to open the Parameter Configuration dialog.
- In the Parameter Name field, enter
REPORT_CONNECTION. - Click
to open the Expression Editor. - In the first column, select Parameters.
- In the center column, double-click REPORT_CONNECTION parameter connection to add it to the editor field, and click Finish. The expression appears in the Parameter Configuration field.
- Click OK and confirm that the parameter has been added to the Part Parameters list, then click Finish.