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.
Asked
Active
Viewed 1,214 times
1
-
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 Jul 26 '20 at 03:55
-
For one operation i can read it in small chunks, For the other I have to load the complete file. – hina Jul 26 '20 at 03:58
-
This problem doesn't seem related to Swing. Tag removed. – Andrew Thompson Jul 26 '20 at 04: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 Jul 26 '20 at 04: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 space – Nishit Jul 26 '20 at 12:25
-
@ Andrew Thompson With one excel file I have to just read the excel data and store it in the database. With the second excel file I have to read and Perform few operations and write it back to the same file. – hina Jul 26 '20 at 16:57
1 Answers
2
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.

Alex Voss
- 147
- 9