jasper-reportsUsing subreports


Parameters

ParameterDetails
parametersMapExpressionThe Map with parameters. Not required
subreportParameterThe pair of name and value (set with subreportParameterExpression). Not required. Several parameters can be passed to subreport
connectionExpressionConnection for getting data. Not required
dataSourceExpressionExpression for passing Datasource. Not required
subreportExpressionThe subreport's path/URI or even JasperReport object. Not required
returnValueThe pair of name and value. Not required. Several values can be returned from subreport to master report back

Remarks

  • Subreports can be used for constructing complex reports. The reusing of existing reports is another goal of using subreports.

  • The subreport will be shown as a part of master report in case using of <subreport> element.

  • The value of subreportExpression parameter is differ for using at JasperReports Server or just by JasperReports framework (some API using or using in IDE).

    For JasperReports Server it looks like:

    <subreportExpression><![CDATA["repo:subreport.jrxml"]]></subreportExpression>
    

    For using by just JasperReports engine:

    <subreportExpression><![CDATA["/somePath/subreport.jasper"]]></subreportExpression>
    

    The great explanation by @AndreasDietrich can be found at JasperServer: Unable to locate the subreport exception post

  • For some reasons the subreport can be used as a common report - without calling from the master report (with help of <subreport> element). The subreport is always a report.