I copy XSSFWorkbook
to SXSSFWorkbook
. In this process, I create the new workbooks I use like this:
XSSFWorkbook readOnlyWb = (XSSFWorkbook) WorkbookFactory.create(f, null, true);
SXSSFWorkbook writeOnlyWb = new SXSSFWorkbook();
When writing to disk, the content type of the SXSSFWorkbook
is always
/xl/workbook.xml - Content Type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet.main+xml
This is no issue, if the source workbook is an .xlsx
file which has the same content type.
But I also have .xlsm
files which I want to copy and they should remain to be .xlsm
files. These files have the content type
/xl/workbook.xml - Content Type: application/vnd.ms-excel.sheet.macroEnabled.main+xml
So basically the issue I have is, to dynamically get the right content type for each file type while using SXSSFWorkbook
.
How can I change the content type for the SXSSFWorkbook
dynamically?