Subreport isn't showing

0

Hello, I'm trying to pass a parameter from Java to Jaspersoft including a subreport that I've compiled into a JasperReport and some other values:

def subReport = classPathResourceLoader.getResourceAsStream("classpath:reports/subReport.jrxml");
parameters.put("subReport", JasperCompileManager.compileReport(subReport.get()));

I've also changed the main report's source code to use the parameters passed:

<subreport>
    <parametersMapExpression><![CDATA[$P{REPORT_PARAMETERS_MAP}]]></parametersMapExpression>
    <subreportParameter name="firstName">
        <subreportParameterExpression><![CDATA[$P{firstName}]]></subreportParameterExpression>
    </subreportParameter>
    <subreportExpression><![CDATA[$P{subReport}]]></subreportExpression>
</subreport>

As you can see I've also passed another parameter called firstName and I'm displaying it as well, however the subreport still isn't showing. What am I lacking? I hope you can help, thanks.

blamblam's picture
Joined: Apr 26 2021 - 6:37pm
Last seen: 21 hours 12 min ago

<subreport>

<!-- This is the size of your report -->

<reportElement x="0" y="0" width="200" height="100" uuid="8f4cd4e3-6e61-4116-baa9-7f819d8fc142"/>

<subreportParameter name="param">

          <subreportParameterExpression><![CDATA[$P{param}]]></subreportParameterExpression>

</subreportParameter>

<!-- By Default you have to put this  -->   

 <connectionExpression><![CDATA[$P{REPORT_CONNECTION}]]></connectionExpression>

 <!-- Here is the path of your jasper file -->        

 <subreportExpression><![CDATA[C:\subReport.jasper"]]></subreportExpression>

 <!-- you can pass also using parameter -->        

 <subreportExpression><![CDATA[$P{subReportPath}]]></subreportExpression>

</subreport>

mahadiosb - 2 days 11 hours ago

Thank you, I can't believe I missed that.

blamblam - 23 hours 24 min ago

0 Answers:

No answers yet
Feedback