File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

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

 
Shaveta Sharma
Greenhorn
Posts: 1
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 9214
9
Linux Mac OS X Windows
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic