Subreports in Jasper Reports

Subreport is an advanced feature of Jasper Reports and is used to design complex reports. Subreport is a report inside another report. The datasource connection used by the Subreport is same as the parent report.

 

 

From the iReport Designer palette, we can select the subreport element and drop it in the master report to create a subreport. Now a subreport wizard opens which gives the option to create a new report or modify existing report. Here, we can define the data source connection also. Once the subreport is created, we can add fields to the subreport as in a normal report.

 

Now, the subreport element is added in the main report.

 

Now, select the properties of the subreport and set the ‘Connection type’ as ‘Use a DataSource Expression’ and  ‘Data Source Expression’ as  ‘$P{SR_DATA_SOURCE}’ (any name as you wish)  with the parameter class as java.lang.Object. With these parameters set, we can create a subreport inside a master report.

Comments

priyanka: how i can add parameter in openerp using jasper report?".

Leave a Reply

Your email address will not be published. Required fields are marked *

  1. Anonymous says:

    Hi, I am trying to add a sub report to my main report and it compiles but my sub-report is not visible when i run it with the main report. Individually the sub report runs fine by itself.
    I am passing a parameter map and no connection to the main report and am not sure what i should pass as the Connection Type and Data Source Expression. I tried passing ${SR_DATA_SOURCE} as you suggested but the compiler complains that it can’t find the parameter. Am i missing something?? Thanks!

  2. priyanka says:

    how i can add parameter in openerp using jasper report?

© 2020 Zesty Beanz Pvt Ltd All Rights Reserved.