简体   繁体   English

Jasper Sub Report未显示在PDF中

[英]Jasper Sub Report not shown in PDF

I am having problem with Jasper Sub Reports. 我在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. 两种JRXML都可以正确编译,这没有问题。 But I'm not able to get the Sub report data in generated pdf file. 但是我无法在生成的pdf文件中获取Sub报告数据。

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. 可能发生了这样的情况,您为子报告指定的路径解析为不存在.jrxml / .jasper文件的路径,因此子报告未生成。 This is a very common mistake. 这是一个非常常见的错误。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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