Blank subreport in Jasper Reports

安稳与你 提交于 2019-12-24 04:23:17

问题


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.

What I've done so far:

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

  • The subreport expression in the main report is set to: $P{SUBREPORT}

  • The subreport connection expression is: $P{REPORT_CONNECTION}

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

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?

Thanks in advance, Andy.


回答1:


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.

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



来源:https://stackoverflow.com/questions/2564674/blank-subreport-in-jasper-reports

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!