[ACCEPTED]-JasperReports: How to pass parameter to subReport-jasper-reports

Accepted answer
Score: 38

Try using iReport if you are not.

When viewing a 10 report within iReport you can select the 9 properties of the subreport within the main 8 report.

In this there is an option in Subreport properties called 7 Parameters. Using this you can pass parameters to 6 your subreport.

  • Select this and click the 5 Add button.

  • Then click the button right of the Value expression Box

  • Next 4 an option screen will pop up where you can 3 select the parameter from the master report 2 you want to pass.

If you want to do it via 1 xml here's a quick example.

<subreport>
    <subreportParameter name="XML_ID">
        <subreportParameterExpression>
            <![CDATA[$P{MASTER_REPORT_PARAMETER}]]></subreportParameterExpression>
    </subreportParameter>
</subreport>

More Related questions