JasperReports and iReports tutorial for JAVA using subreports with different datasources

Here at RationalPlan we are working on a way to generate reports. We chose JasperReports for Java and iReports as the graphical interface for a visual creation of the report layout. It is a daunting task because there are no tutorials which describe in detail how to create a master report with many subreports each  with their different datasource and if you want to read the documentation you have to pay for it. After accomplishing what we proposed we thought that is a good idea to share our knowledge and experience.

1. Creating the main report layout

First let’s start by opening iReport and creating the main report as shown in the figure (in this tutorial there were used the latest versions of  iReport(3.7.6) and JasperReports(3.7.6)).

main report layout

If you don’t know how to make the main report to look like this search about iReports tutorial on different search engines or post here and we shall try to help you as much as we can. After finishing it press the “Preview” button and if there are no errors in the iReport console then you can compile your report by clicking “Compile report” icon. A new file with the .jasper extension will be created in the same folder as the .jrxml file.

2. Creating the main report custom datasource

After successfully completing the first step you must create the custom datasource in your java application. (more…)