I'm tring to to read large excel file (size~10MB,.xlsx) .
I'm using below code
Workbook xmlworkbook =WorkbookFactory.create(OPCPackage.openOrCreate(root_path_name_file));
But it's showing Heap memory issue.
I have also seen other solution on StackOverflow some of them given to increase the JVM but i dont want to increase jvm.
Issue 1) We can't use SXSSF (Streaming Usermodel API)
because this is only for writing or creating new workbook.
My sole objective to get the number of NamedRange of sheet, Total number of sheet and their sheet name for large excel file.
If the requirement is only to get the named ranges and sheet names, then only the
/xl/workbook.xml
from the*.xlsx
ZIPPackage
must be parsed since those informations are all stored there.This is possible by getting the appropriate
PackagePart
and parsing theXML
from this. For parsingXML
my favorite is usingStAX
.Example code which gets all sheet names and defined named ranges: