Reputation: 61
We are currently using TIBCO Jaspersoft Studio, jasperreports-6.5.1 librarу in our Java application. When we export the report with both JRXlsExporter
and JRXlsxExporter
, we get a popup with text Excel found unreadable content in 'xxx.xls'. Do you want to recover the contents of this workbook? If you trust the source of this workbook, click yes.
.
When we run the same report from Jaspersoft Studio preview we get Excel file, which is opened without error. We just fount out the the problem in style.xml for xlsx file. Any suggestion will be appreciated.
Upvotes: 1
Views: 1146
Reputation: 61
At least I found out the reason. It happens because Excel does not support date format "EEEEE dd MMMMM yyyy" which was used in jrxml file. So java code
SimpleXlsxReportConfiguration configuration = new SimpleXlsxReportConfiguration();
Map<String, String> dateFormats = new HashMap<String, String>();
dateFormats.put("EEEEE dd MMMMM yyyy", "ddd, mmm d, yyyy");
configuration.setFormatPatternsMap(dateFormats);
XlsxExporter.setConfiguration(configuration);
XlsxExporter.exportReport();
fixes the issue. I hope it helps somebody else
Upvotes: 1