如何将jasper文件路径传递给子报表的子报表 [英] how to pass jasper file path to subreport of subreport
问题描述
我正在使用iReport工具和JasperReports 1.3.4。
I am using iReport tool in conjunction with JasperReports 1.3.4.
我有一个主报告,其中包含两个子报告。其中一个子报表具有嵌入式子报表。所有.jasper文件都驻留在同一目录中。
I have a master report, which contain two subreports. One of these subreports has an embedded subreport. All of the .jasper files reside in the same directory.
iReport生成了一个名为 SUBREPORT_DIR
的参数。 subreportExpression将子报告文件名表示为![CDATA [$ P {SUBREPORT_DIR} +subreport.jasper]
。
iReport generated the parameter called SUBREPORT_DIR
. The subreportExpression expresses the subreport filename as ![CDATA[$P{SUBREPORT_DIR} + "subreport.jasper"]
.
从iReport内部生成报告时,一切都很有效。但是,我有一个小的Java Web应用程序,我试图用来生成报告。我将SUBREPORT_DIR
参数传递给 JasperFillManager.fillReport(String sourceFileName,Map parameters,JRBeanCollectionDatasource)
。此 SUBREPORT_DIR
设置为主报告所在的目录。
Everything works great when the report is generated from within iReport. But, I have a small Java web appplication that I am trying to use to generate reports. I pass a "SUBREPORT_DIR"
parameter to JasperFillManager.fillReport(String sourceFileName, Map parameters, JRBeanCollectionDatasource)
. This SUBREPORT_DIR
is set to the directory in which the master report is located.
fillReport抛出异常:
fillReport throws an exception:
net.sf.jasperreports.engine.JRException: Could not load object from location :
.sub-subreport.jasper.
看来第一个子报表正在尝试处理其子报表(嵌入式子报表) )
,但 SUBREPORT_DIR
未解析,或正确用于生成子子报告的名称。
It appears that the first subreport is trying to process its subreport(embedded subreport)
, but the SUBREPORT_DIR
is not being resolved, or used properly to generate the name of the sub-subreport.
我有什么遗漏的吗?如何处理这种情况?
Is there something I'm missing? How should this scenario be handled?
推荐答案
点击 Subreport1
,去到属性标签 - >子报告属性 - >参数
您将传递' MasterReport ' SUBREPORT_DIR
参数作为' Subreport1 '的参数。
创建此条目:
You will pass your 'MasterReport' SUBREPORT_DIR
parameter as a parameter to 'Subreport1'.
Create this entry:
名称: SUBREPORT_DIR
表达式: $ P {SUBREPORT_DIR}
不要忘记重新编译报告,并确保在应用程序服务器中重新发布您的Web应用程序。
Don't forget to recompile your reports and make sure to republish your web app in the application server.
这篇关于如何将jasper文件路径传递给子报表的子报表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!