This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
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


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
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: 8843
    
    7

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


"blabbing like a narcissistic fool with a superiority complex" ~ N.A.
[How To Ask Questions On JavaRanch]
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: How to read excel file of 2MB and having around 200 sheets
 
Similar Threads
poi and protected excel book
reading password protected excel sheet
error reading excel file using apache poi
Error while trying to construct excel sheet..!
ClassCastExcepiton Using POI