I've tried to initialize an XSSFWorkbook with an Excel file with the .xlsm extension using Apache POI in Java, but it's taking a lot of time to load the file (I've already waited 1 hour and it was still loading). The xlsm file itself is fairly small (1MB), has 50 sheets (each sheet has one table constituted by 5x20 cells) and a Macro script. The code I'm currently using is:
String templateFilePath = filePath + fileName + ".xlsm";
XSSFWorkbook newWorkBook = new XSSFWorkbook(templateFilePath);
Please note that I've tried to load the file using:
Workbook newWorkBook = WorkbookFactory.create(new FileInputStream(templateFilePath) );
Files.readAllBytes(Paths.get(templateFilePath));
File file = new File(templateFilePath);
File file = new File(templateFilePath);
OPCPackage opcPackage = OPCPackage.open(file);
XSSFWorkbook newWorkBook = new XSSFWorkbook(opcPackage);
... And still got the same results. Also, I've tried other file extensions (.xlsx and .xls) to no avail.
Other notes: No memory errors are displayed. It just keeps infinitely loading the file. I've made another test where I deleted some sheets from the file and left only 8. That way the "newWorkBook" was successfully initialized. However, I need to read the file with all the sheets so I'd like to know if there is another way to do so.