简体   繁体   中英

Jasper Sub Report not shown in PDF

I am having problem with Jasper Sub Reports. I have a report template that has a subreport; in main report I have some parameters that should be available in subreport too.

Main report parameter is :

<parameter name="mainParameter" class="java.lang.Object"/>

Subreport report parameter is :

<parameter name="mainParameter" class="java.lang.Object"/>

And I provided parameters of master report for sub report like this:

<subreport isUsingCache="false">
    <reportElement x="0" y="1450" width="200" height="50" isRemoveLineWhenBlank="true"/>
    <subreportParameter name="mainParameter">
        <subreportParameterExpression><![CDATA[$P{mainParameter}]]></subreportParameterExpression>
    </subreportParameter>
    <subreportExpression class="java.lang.String"><![CDATA["subReport.jasper"]]></subreportExpression>
</subreport>

Both the JRXML's were compiling properly, no issues with that. But I'm not able to get the Sub report data in generated pdf file.

To ensure the sub report runs/generate properly, please see that the connection from the main report is passed to the sub report. Also, the parameters which are to be used from Main Report, should be same in name and case in sub report otherwise the mapping will fail.

Please also check the relative and absolute path for the sub report from the main report. It might have so happened that path you gave for sub report is resolving to a path where the .jrxml/.jasper file is not present and therefor the sub report is not getting generated. This is a very common mistake.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM