0
當導出使用Java API創建的使用ireport designer 5.0.1創建的JasperReport時,報告始終爲空。在報告中,我已經在iREPORT分享到人人正確使用JRRtfExporter結果是蠻好的設置whenNoDataType =「AllSectionsNoDetail。同時使用新JREmptyDataSource()也不起作用。JasperReport PDF導出空,RTF導出正常
還當我導出爲RTF。另外,PDF預覽。
InputStream inputStream = this.getClass().getResourceAsStream("/test-report.jasper");
ByteArrayOutputStream out = new ByteArrayOutputStream();
JasperPrint jPrint = JasperFillManager.fillReport(inputStream, new HashMap<String, Object>(), new JRXmlDataSource(new ByteArrayInputStream("<root><name>John Doe</name</root>".getBytes("UTF-8")), "/root"));
JRPdfExporter reportExporter = new JRPdfExporter();//JRRtfExporter(); does works fine
reportExporter.setParameter(JRExporterParameter.JASPER_PRINT, jPrint);
reportExporter.setParameter(JRExporterParameter.OUTPUT_STREAM, out);
reportExporter.exportReport();
out.close();
reportBytes = out.toByteArray();
reportBytes被保存到磁盤。