Jasper Reports中的空白子报告 [英] Blank subreport in Jasper Reports
问题描述
我正在尝试启动我在iReport中创建的报告,其中包含主报告和子报告。在iReport中,子报表启动正常并包含数据,但是当我尝试从我的java代码中启动它时,子报表是空白的。
I'm trying to launch a report that I created in iReport which contains a main report and a subreport. In iReport, the subreport launches fine and contains data, however when I try to launch it from within my java code, the subreport is blank.
我做了什么远:
-
主报表中有一个名为SUBREPORT的String参数,用于定义子报表的路径。例如。值:E:\ _java \ReportLauncher \\ \\ _reports \ test_subreport1.jasper
I have a String parameter in the main report called "SUBREPORT" that is used to define the path to the subreport. E.g. value: "E:\java\ReportLauncher\reports\test_subreport1.jasper"
主报表中的子报表表达式设置为:$ P {SUBREPORT}
The subreport expression in the main report is set to: $P{SUBREPORT}
子报表连接表达式为:$ P {REPORT_CONNECTION}
The subreport connection expression is: $P{REPORT_CONNECTION}
我还定义了一个名为INVOICE_NUMBER的子报表参数,该参数设置为$ F {InviInvNo},映射到主报表中的字段。
I also have a subreport parameter defined called "INVOICE_NUMBER" that is set to $F{InviInvNo}, which maps to a field in the main report.
在我的java代码中,我有:
In my java code, I have:
HashMap<String, Object> paramHash = new HashMap();
paramHash.put("INVOICE_NUMBER", invoiceID);
paramHash.put("REPORT_CONNECTION", this.conn);
paramHash.put("SUBREPORT", subReportPath);
JasperPrint jasperprint = JasperFillManager.fillReport(this.reportPath, paramHash, this.conn);
主报告已正确创建并已填充。然而,子报告区域是空白的。对于我做错了什么的任何想法?
The main report is created fine and is populated. The subreport area however is blank. Any thoughts for what I'm doing wrong?
提前致谢,
Andy。
Thanks in advance, Andy.
推荐答案
由于您没有提及有关子报表查询的任何内容:
Since you didn't mention anything about the subreport query:
如果您在子报表中使用详细信息区域,那么您将需要报告的数据查询。
If you are using the Detail Band in the subreport, then you will need a Data Query for the report.
在旧的iReport中,从数据
菜单中选择报告查询
并在此处写下您的查询。如果只需要一个记录(即只有一次详细信息带),则可以使用虚拟表。喜欢:
In old iReport, from Data
menu, choose Report Query
and write your query here. If you want only one record (i.e. Detail band only one time) you can use a dummy table. Like:
SELECT 'a' FROM DUMMY
否则,如果您不想使用细节带,您可以选择在不使用查询的情况下查看其他带。从编辑
菜单中,选择报告属性
,更多...
标签,设置标志当没有数据
到所有部分,没有细节
Otherwise, if you don't want to use the Detail Band, you have the option to view the other bands without using a query. From Edit
menu, choose Report Properties
, under More...
tab, set the flag When no data
to All Sections, no detail
这篇关于Jasper Reports中的空白子报告的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!