aspose file tools*
The moose likes I/O and Streams and the fly likes How to read excel file of 2MB and having around 200 sheets Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » I/O and Streams
Bookmark "How to read excel file of 2MB and having around 200 sheets" Watch "How to read excel file of 2MB and having around 200 sheets" New topic
Author

How to read excel file of 2MB and having around 200 sheets

Shaveta Sharma
Greenhorn

Joined: Jul 30, 2010
Posts: 1
Hi,

I am writing a program to read excel file using POI. My file is of 2MB and has 200 sheets.
At run time I am getting below error:
Exception in thread "main" java.lang.OutOfMemoryError: Java heap space
at java.lang.Integer.valueOf(Unknown Source)
at org.apache.poi.hssf.usermodel.HSSFSheet.addRow(HSSFSheet.java:299)
at org.apache.poi.hssf.usermodel.HSSFSheet.createRowFromRecord(HSSFSheet.java:218)
at org.apache.poi.hssf.usermodel.HSSFSheet.setPropertiesFromSheet(HSSFSheet.java:142)
at org.apache.poi.hssf.usermodel.HSSFSheet.<init>(HSSFSheet.java:117)
at org.apache.poi.hssf.usermodel.HSSFWorkbook.<init>(HSSFWorkbook.java:288)
at org.apache.poi.hssf.usermodel.HSSFWorkbook.<init>(HSSFWorkbook.java:201)
at org.apache.poi.hssf.usermodel.HSSFWorkbook.<init>(HSSFWorkbook.java:183)
at ReadXMLTemplate.readSDDBTmpl(ReadXMLTemplate.java:117)

Please help..
Joe Ess
Bartender

Joined: Oct 29, 2001
Posts: 8968
    
    9

Welcome to the JavaRanch.
The solution to your problem may be as simple as increasing the heap size. You do that with the -Xmx command line switch. see here

I see you are using POI. There is an event-based model that may be more memory efficient than the user model when working with large files. see here


[How To Ask Questions On JavaRanch]
 
 
subject: How to read excel file of 2MB and having around 200 sheets