我很熟悉jasperstudio 6.3.0,並且能夠從java運行其他報告而沒有任何問題。效果很好。但是,我無法運行包含子報表的報表。我在這裏找到了解決方案,但仍然無法使其工作。在我的解決方案中,我將報告加載到表中進行存儲,並從數據庫中提取子報表和主報表並編譯jrxml。一切工作正常,然後在java中調用Jasper子報告
net.sf.jasperreports.engine.JRException:資源未找到:subInvoiceSummary.jasper。 runReport中的錯誤:找不到資源:subInvoiceSummary.jasper。 at net.sf.jasperreports.repo.RepositoryUtil.getResourceFromLocation(RepositoryUtil.java:153) at net.sf.jasperreports.repo.RepositoryUtil.getReport(RepositoryUtil.java:112) at net.sf.jasperreports.engine。在net.sf.jasperreports.engine.fill.JRFillSubreport.evaluateReport(JRFillSubreport.java:365) at net.sf.jasperreports.engine.fill.JRFillSubreport.evaluateSubreport(JRFillSubreport.java:398) JRFillSubreport.java:427) 在net.sf.jasperreports.engine.fill.JRFillSubreport.evaluate(JRFillSubreport.java:341) 在net.sf.jasperreports.engine.fill.JRFillElementContainer.evaluate(JRFillElementContainer.java:381)at net.sf.jasperreports.engine.fill.JRFillBand.evaluate(JRFillBand.java:500) at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillColumnBand(JRVerticalFiller.java:2022) at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillDetail(JRVerticalFiller.java:748) at net.sf. jasperreports.engine.fill.JRVerticalFiller.fillReportStart(JRVerticalFiller.java:255) at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillReport(JRVerticalFiller.java:115) at net.sf.jasperreports.engine.fill。 JRBaseFiller.fill(JRBaseFiller.java:580) at net.sf.jasperreports.engine.fill.BaseReportFiller.fill(BaseReportFiller.java:396) at net.sf.jasperreports.engine.fill.JRFiller.fill(JRFiller。 java:90) at net.sf.jasperreports.engine.JasperFillManager.fill(JasperFillManager.java:456) at net.sf.jasperreports.engine.JasperFillManager.fillRe端口(JasperFillManager.java:863)
我已經嘗試了很多排列但無濟於事。我也試着拉入jasperreports的代碼來跟蹤上面顯示的堆棧,但有很多.jar依賴和版本的依賴我無法在2天后讓它在我的項目中編譯乾淨(如果任何人有鏈接一個簡單的方法來做這項工作,請讓我知道)。以下是代碼片段:
Map<String, Object> rptParms = new HashMap<String, Object>();
List<daRecOnDemandSubReport> subReports = report.getOnDemandSubReport();
Iterator<daRecOnDemandSubReport> subReportList = subReports.iterator();
while (subReportList.hasNext()) {
daRecOnDemandSubReport subReport = subReportList.next();
ByteArrayInputStream x = getSubReportDataStream(dbConnROIPro, report.getODReportID());
JasperReport compiledSubReport = JasperCompileManager.compileReport(x);
String fileName = subReport.getODSubReportFileName().replace(".jrxml", ".jasper");
rptParms.put(fileName, compiledSubReport);
}
ByteArrayInputStream x = getReportDataStream(dbConnROIPro, report.getODReportID());
JasperReport cRpt = JasperCompileManager.compileReport(x);
rptParms = getReportParameters(dbConnGTrack,report.getODReportID(), rptParms, report.getOnDemandParm(), programID);
JasperPrint rpt = JasperFillManager.fillReport(cRpt,rptParms,dbConnGTrack.getDbConn());
ByteArrayOutputStream outStream = new ByteArrayOutputStream();
JRXlsxExporter XLSXexporter = new JRXlsxExporter();
XLSXexporter.setExporterInput(new SimpleExporterInput(rpt));
XLSXexporter.setExporterOutput(new SimpleOutputStreamExporterOutput(outStream));
XLSXexporter.exportReport();
預先感謝任何幫助