[英]Jasper Reports print unconfigured report in xlsx, docx, csv, rtf, etc
[英]Jasper Reports - Set Document properties (author, title..) in docx, xlsx, odt
有没有办法在 Jasper Reports from Java 中设置 docx、xlsx 和 odt 的文档属性(如作者、标题和评论)? 我有 Jasper Reports 的 3.7.0 版本。
此代码可能对您有用
JasperPrint jasperPrint = JasperFillManager.fillReport(jasperPath + "myReport.jasper", hm, con);
JRPdfExporter exporter = new JRPdfExporter();
exporter.setParameter(JRExporterParameter.JASPER_PRINT, jasperPrint);
exporter.setParameter(JRExporterParameter.OUTPUT_FILE, outPath + outFile);
exporter.setParameter(JRPdfExporterParameter.METADATA_AUTHOR, "Adnan");
exporter.setParameter(JRPdfExporterParameter.METADATA_TITLE, "Title");
// ...
exporter.exportReport();
使用 jasperreports 6.7.0
PDF格式
final SimplePdfExporterConfiguration config = new SimplePdfExporterConfiguration();
config.setMetadataTitle("ABC");
config.setMetadataAuthor("XYZ");
final JRPdfExporter exporter = new JRPdfExporter();
exporter.setConfiguration(config);
单词
SimpleDocxExporterConfiguration config= new SimpleDocxExporterConfiguration();
config.setMetadataTitle("ABC");
config.setMetadataAuthor("XYZ");
final JRDocxExporter exporter = new JRDocxExporter();
exporter.setConfiguration(config);
优秀
final SimpleXlsxExporterConfiguration config= new SimpleXlsxExporterConfiguration();
config.setMetadataAuthor("ABC");
config.setMetadataTitle("XYZ");
final JRXlsxExporter exporter = new JRXlsxExporter();
exporter.setConfiguration(config);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.