You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@poi.apache.org by maitrey <ma...@gmail.com> on 2018/01/23 14:22:13 UTC

XSSFWorkbook throws outofMemoryError

My file is 50MB and I got outofMemoryError in this statement.
XSSFWorkbook workbook = new XSSFWorkbook(excelFilePath); 

this line causes to  java.lang.OutOfMemoryError: Java heap space

We have search and try to apply the solutions like SXSSF classes,
StreamReader classes and SAX parser.
But this needs big implementation in our application.
We have the heap memory to 2GB but still we get this error.

Is there any way to use this constuctor? 
we need workbook object. It is extensive used in application.
I know there are similar questions like this. I have also tried to apply
suggetions but it is not completly works in our case.



--
Sent from: http://apache-poi.1045710.n5.nabble.com/POI-User-f2280730.html

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@poi.apache.org
For additional commands, e-mail: user-help@poi.apache.org


Re: XSSFWorkbook throws outofMemoryError

Posted by "pj.fanning" <fa...@yahoo.com>.
https://github.com/monitorjbl/excel-streaming-reader supports reading Excel
docs but allows use of Workbook Model APIs based on the POI Workbook Model.



--
Sent from: http://apache-poi.1045710.n5.nabble.com/POI-User-f2280730.html

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@poi.apache.org
For additional commands, e-mail: user-help@poi.apache.org


Re: XSSFWorkbook throws outofMemoryError

Posted by micofo <pr...@gmail.com>.
Hello, 

I think it is not later for you
this snippet of code can help you:

InputStream is = new FileInputStream(new File(myfile.xlxs));
		Workbook workbook = StreamingReader.builder()
		        .rowCacheSize(100)    // number of rows to keep in memory
(defaults to 10)
		        .bufferSize(4096)     // buffer size to use when reading
InputStream to file (defaults to 1024)
		        .open(is); 

//And you continue with your code



--
Sent from: http://apache-poi.1045710.n5.nabble.com/POI-User-f2280730.html

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@poi.apache.org
For additional commands, e-mail: user-help@poi.apache.org


Re: XSSFWorkbook throws outofMemoryError

Posted by Jörn Franke <jo...@gmail.com>.
50 mb compressed can easily be several hundred MBs uncompressed. Especially with Java Datentypes. You should increase the memory by at least 2 other GB, if you want to stay with your current solution.

Depending on your workbook structure you could skip reading sheets which are not relevant or just read one after the other. The following example uses this as part of hybrid streaming, but you could follow the same approach with the normal api(read only one sheet and ignore the others):
https://svn.apache.org/repos/asf/poi/trunk/src/examples/src/org/apache/poi/xssf/streaming/examples/HybridStreaming.java

I use the streaming classes as part of HadoopOffice (including support for encryption and digital signature) it is not so difficult to use.

> On 23. Jan 2018, at 15:22, maitrey <ma...@gmail.com> wrote:
> 
> My file is 50MB and I got outofMemoryError in this statement.
> XSSFWorkbook workbook = new XSSFWorkbook(excelFilePath); 
> 
> this line causes to  java.lang.OutOfMemoryError: Java heap space
> 
> We have search and try to apply the solutions like SXSSF classes,
> StreamReader classes and SAX parser.
> But this needs big implementation in our application.
> We have the heap memory to 2GB but still we get this error.
> 
> Is there any way to use this constuctor? 
> we need workbook object. It is extensive used in application.
> I know there are similar questions like this. I have also tried to apply
> suggetions but it is not completly works in our case.
> 
> 
> 
> --
> Sent from: http://apache-poi.1045710.n5.nabble.com/POI-User-f2280730.html
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@poi.apache.org
> For additional commands, e-mail: user-help@poi.apache.org
>