Jasper Sub报告未以PDF格式显示 [英] Jasper Sub Report not shown in PDF

查看:153
本文介绍了Jasper Sub报告未以PDF格式显示的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我遇到了Jasper Sub Reports的问题。我有一个包含子报表的报表模板;在主报告中,我有一些参数也应该在子报表中可用。

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.

主要报告参数是:

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

子报告报告参数是:

<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>

JRXML都正确编译,没有问题。但是我无法在生成的pdf文件中获取Sub报告数据。

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.

请同时检查亲属和主报告中子报告的绝对路径。可能发生了这样的情况:您为子报告提供的路径正在解析为不存在.jrxml / .jasper文件的路径,因此未生成子报告。这是一个非常常见的错误。

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.

这篇关于Jasper Sub报告未以PDF格式显示的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆