Igo*_*gor 3 java jasper-reports
我有一个不同的问题...我用谷歌搜索了一下,但没有找到任何关于我的问题的信息,所以我在这里问...我有一个对象 JasperPrint,我在其中生成文档...问题是我需要创建一个来自此 JasperPrint 的 java.io.File 而不将文件保存在计算机上。
我需要做的是:通过电子邮件发送文件。并且这个文件必须由jasperreport生成。我无法将流保存在机器上以便稍后删除它...所以我需要在运行时将文件保存在内存中或类似的东西...
所以...我有我的对象 jasperprint 并且需要从中获取一个 java.io.File...有人知道我能做什么?
安德鲁...无法在评论中回答它,所以我在这里写...在 javax.mail 中我这样做了:
File fileAttachment = myfile;
messageBodyPart = new MimeBodyPart();
DataSource source = new FileDataSource(fileAttachment);
messageBodyPart.setDataHandler(new DataHandler(source));
messageBodyPart.setFileName(fileAttachment.getName());
multipart.addBodyPart(messageBodyPart);
Run Code Online (Sandbox Code Playgroud)
当我从我的机器上向他传递一个文件时它会工作...所以我认为当我使用 java.io.File 时它会工作即使它只在内存中...
您可以将报告生成为 PDF(或其他格式)并将其作为文件发送给 Jasper。JRXls出口商
一些片段:
JasperPrint print = JasperFillManager.fillReport(report, new HashMap(), jasperReports);
long start = System.currentTimeMillis();
OutputStream output = new FileOutputStream(new File("c:/output/JasperReport.pdf"));
JasperExportManager.exportReportToPdfStream(print, output);
// coding For Excel:
JRXlsExporter exporterXLS = new JRXlsExporter();
exporterXLS.setParameter(JRXlsExporterParameter.JA SPER_PRINT, print);
exporterXLS.setParameter(JRXlsExporterParameter.OU TPUT_STREAM, output);
exporterXLS.setParameter(JRXlsExporterParameter.IS _ONE_PAGE_PER_SHEET, Boolean.TRUE);
exporterXLS.setParameter(JRXlsExporterParameter.IS _AUTO_DETECT_CELL_TYPE, Boolean.TRUE);
exporterXLS.setParameter(JRXlsExporterParameter.IS _WHITE_PAGE_BACKGROUND, Boolean.FALSE);
exporterXLS.setParameter(JRXlsExporterParameter.IS _REMOVE_EMPTY_SPACE_BETWEEN_ROWS, Boolean.TRUE);
exporterXLS.exportReport();
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
29706 次 |
| 最近记录: |