'Jasper Reports - Set Document properties (author, title..) in docx, xlsx, odt
Is there any way to set document properties (such as author, title and comment) of docx, xlsx and odt in Jasper Reports from Java? I have a version 3.7.0 of the Jasper Reports.
Solution 1:[1]
This code may be useful for you
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();
Solution 2:[2]
With jasperreports 6.7.0
final SimplePdfExporterConfiguration config = new SimplePdfExporterConfiguration();
config.setMetadataTitle("ABC");
config.setMetadataAuthor("XYZ");
final JRPdfExporter exporter = new JRPdfExporter();
exporter.setConfiguration(config);
WORD
SimpleDocxExporterConfiguration config= new SimpleDocxExporterConfiguration();
config.setMetadataTitle("ABC");
config.setMetadataAuthor("XYZ");
final JRDocxExporter exporter = new JRDocxExporter();
exporter.setConfiguration(config);
EXCEL
final SimpleXlsxExporterConfiguration config= new SimpleXlsxExporterConfiguration();
config.setMetadataAuthor("ABC");
config.setMetadataTitle("XYZ");
final JRXlsxExporter exporter = new JRXlsxExporter();
exporter.setConfiguration(config);
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Anand saga |
| Solution 2 | RVL |
