• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

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

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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..
 
Bartender
Posts: 9626
16
Mac OS X Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
reply
    Bookmark Topic Watch Topic
  • New Topic