I have a main Report in jaspersoft. Inside the main Report I have used two SubReports. Inside one of the subreport i have a variable Total Cash. I have to use this variable Total Cash in my next subReport. Is it possible to pass a variable from one SubReport to another SubReport. If not then how can i pass the variable from the SubReport to the main Report.
Thanks.
You can get a return value from a sub-report to the main-report using the returnValue element. The following code sets the $V{result} value in the main-report to the value of $V{total} in the sub-report. This is much more obvious in iReport instead of jrxml code. Take a look at Subreports for more information.
<subreport isUsingCache="true">
<reportElement x="18" y="11" width="189" height="77" key="subreport-1" />
<connectionExpression>
<![CDATA[$P{REPORT_CONNECTION}]]>
</connectionExpression>
<returnValue subreportVariable="total" toVariable="result" />
<subreportExpression class="java.lang.String">
<![CDATA["C:/Program Files/JasperSoft/iReport-3.0.0/compile/Untitled_report_2.jasper"]]>
</subreportExpression>
</subreport>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With