'How to improve upload time of a spreadsheet in memory (XSSFWorkbook) using apache POI

We got a lambda based app which uses a spreadsheet (10MB size) and we are getting some issues due to the time it takes to load the spreadsheet in memory. For managing excel files we are using Apache POI and specifically we upload the spreadsheet creating the XSSFWorkbook object based on an inputStream as follows:

InputStream stream = this.class.classLoader.getResourceAsStream("fileName.xlsx")
XSSFWorkbook workbookInstance = new XSSFWorkbook(stream)

this approach takes between 7 - 9 seconds to load. This is problematic because either if you use it at the init phase or execution phase of the lambda you are getting the first response after >10 seconds.

Is there any optimized way we can create this object using Apache POI? or maybe a different approach that can save us time?

Thanks.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source