【问题标题】:Grails Jasper SubreportGrails Jasper 子报表
【发布时间】:2012-07-04 03:49:40
【问题描述】:

我正在使用 grails,并且我有这个 Jasper 报告,其中包含一个子报告。 有了这个简单的两个碧玉报告

注意:只有 .jrxml 是 /web-app/reports 内文件的文件扩展名

主报告[main_report][子报告区域]

<subreport>
   <reportElement x="0" y="0" width="555" height="157"/>
   <subreportExpression>
      <![CDATA[$P{SUBREPORT_DIR} + "test_report.jasper"]]>
   </subreportExpression>
</subreport>

测试报告[test_report][title.band]

<staticText>
   <reportElement x="203" y="30" width="154" height="34"/>
   <textElement/>
   <text><![CDATA[Hello World]]></text>
</staticText>

查看视图或 gsp 文件我有这个命令

<g:jasperReport jasper="main_report"
                format="pdf, html"
                delimiter=" "/>

当我想查看 HTML 格式的 PDF 报告时,报告会返回一个空白页。我是否缺少使用子报告test_report 正确显示main_report 的内容。

【问题讨论】:

    标签: grails jasper-reports ireport


    【解决方案1】:

    你需要:

    1. 确保子报告已编译(在 iReport 中执行此操作),即报告目录中应有一个 .jasper 文件用于子报告。
    2. 在生成报告之前设置 SUBREPORT_DIR 参数,例如

    params.SUBREPORT_DIR = servletContext.getRealPath('/reports') + "/"

    (假设编译后的子报表在&lt;app&gt;/web-app/reports目录下,和未编译的报表一样)。

    【讨论】:

    • 在尝试您的答案后,main_report 在 grails 运行时编译,但 sub_report 没有。如果main_report 显示sub_report 并且确实如此,我已经检查了IReport。这里缺少什么?
    • 您编译的子报告 (.jasper) 在启动 grails 应用程序之前的报告中?
    • 我已将sub_repoert.jrxml 编译为sub_report.jasper。我还编译了main_report,只是为了确保结果没有变化。只有main_report' is displayed without the sub_report`。
    猜你喜欢
    • 2011-12-25
    • 1970-01-01
    • 2011-02-13
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-12-04
    • 1970-01-01
    相关资源
    最近更新 更多