Java Apache Poi SXSSF with Excel Macros

风流意气都作罢 提交于 2019-12-12 04:12:13

问题


I have a excel template that has macros (.xlsm), I want to read it in, add a million rows to it and write it out.

I know that reading and re-writing files with POI that contain macros will preserve the macros. I need to write out the excel using SXSSF (ram limitations), but SXSSF doesn't read files.

Question: How can I read in an excel with macros using XSSF, and then write out the excel with macros using SXSSF?


回答1:


Apache POI supports writing a spreadsheet with a large number of rows via SXSSFWorkbook based on a "template workbook". See the relevant constructor for details.

So you would open the .xlsm via XSSFWorkbook and then create the SXSSFWorkbook with that as template.

This should also keep the macros in place as far as I see.



来源:https://stackoverflow.com/questions/40555658/java-apache-poi-sxssf-with-excel-macros

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!