I use an xlsm-file with a macro by following property (added in sourcecode of jrxml).
<property name="net.sf.jasperreports.export.xlsx.macro.template" value="dropdown-macro.xlsm"/>
The file dropdown-macro.xlsm is in the same folder like the jrxml-file.
Exporting the xlsx-file with Jaspersoft Studio (6.2.1) works and the macro is working to (manual execution).
When using our own software with jasper library 6.2.1 (including all maven dependencies), and the dropdown-macro.xlsm
in the same path like the jrxml-file, the xlsx-file is corrupt (0 byte).
When I remove the property the report is working again (without macro).
We use Office 365.
Any ideas how to fix that problmen?
I also tried an absolute path:
<property name="net.sf.jasperreports.export.xlsx.macro.template" value="P:\projekte\p564v2\Installationen\iCDData\LABS-Q_ORA-42x\formular\dropdown.xlsm"/>
I get following error:
JRException: Input stream not found at: P:\projekte\p564v2\Installationen\iCDData\LABS-Q_ORA-42x\formular\dropdown.xlsm.
The path is correct, I checked it.
I now get an xlsx file with content, but I cannot open it. It's still "corrupt": File cannot be opend .. file format or extension invalid.
When I rename it to xlsx2 I can open and repair it. Even the macro is working. But that is just a workaround.
I assume it could be connected with right-problems of inserting/linking the macro in/with the xlsx-file, but even when the xlsm file
is in a trusted folder I have the same problem.
I had the same problem and found the reason.
As defined by Microsoft in File formats that are supported in Excel a xlsx is not allowed to have macros in.
Changing the fileextension of the exported (manually) from xlsx -> xslm fixed the problem for me.
No comment about the usability.