I want to read a very large excel file using Apache POI. But it is throwing a heap size out of memory error. There is no chance I can increase the heap size.Are there any other solutions for this.
-
Can you read the file piece wise, by breaking into smaller chunks? Or do you need the entire file in the memory at the same time?Nishit– Nishit2020-07-26 03:55:28 +00:00Commented Jul 26, 2020 at 3:55
-
For one operation i can read it in small chunks, For the other I have to load the complete file.hina– hina2020-07-26 03:58:32 +00:00Commented Jul 26, 2020 at 3:58
-
This problem doesn't seem related to Swing. Tag removed.Andrew Thompson– Andrew Thompson2020-07-26 04:16:34 +00:00Commented Jul 26, 2020 at 4:16
-
"I want to read a very large excel file" BTW - is it for read only? Is there any need to update that information and write the file?Andrew Thompson– Andrew Thompson2020-07-26 04:18:22 +00:00Commented Jul 26, 2020 at 4:18
-
@hina If you have to load the complete file, then you will need the entire file in memory. You cannot do without extra heap spaceNishit– Nishit2020-07-26 12:25:00 +00:00Commented Jul 26, 2020 at 12:25
|
Show 1 more comment
1 Answer
Depending on exactly what you are trying to do, POI's streaming API might be the solution. It avoids loading the whole file into memory at the same time but is limited in its functionality.
The answers to this question might be useful as one of them suggests a library that makes working with the streaming API easier.
1 Comment
will824
Thanks for providing the link to the streaming api library. This helped me greatly!