to read a big excel file in java -


i trying read excel file through java apache poi in netbeans containing 8000 columns , 1200 rows getting following exception. have tried increase heap size in netbeans –xmx2048m doesn’t me out.

    exception in thread "main" java.lang.outofmemoryerror: java heap space     @ org.apache.xmlbeans.impl.store.cur$curloadcontext.attr(cur.java:3039)     @ org.apache.xmlbeans.impl.store.cur$curloadcontext.attr(cur.java:3060)     @ org.apache.xmlbeans.impl.store.locale$saxhandler.startelement(locale.java:3250)     @ org.apache.xmlbeans.impl.piccolo.xml.piccolo.reportstarttag(piccolo.java:1082)     @ org.apache.xmlbeans.impl.piccolo.xml.piccololexer.parseattributesns(piccololexer.java:1802)     @ org.apache.xmlbeans.impl.piccolo.xml.piccololexer.parseopentagns(piccololexer.java:1521)     @ org.apache.xmlbeans.impl.piccolo.xml.piccololexer.parsetagns(piccololexer.java:1362)     @ org.apache.xmlbeans.impl.piccolo.xml.piccololexer.parsexmlns(piccololexer.java:1293)     @ org.apache.xmlbeans.impl.piccolo.xml.piccololexer.parsexml(piccololexer.java:1261)     @ org.apache.xmlbeans.impl.piccolo.xml.piccololexer.yylex(piccololexer.java:4808)     @ org.apache.xmlbeans.impl.piccolo.xml.piccolo.yylex(piccolo.java:1290)     @ org.apache.xmlbeans.impl.piccolo.xml.piccolo.yyparse(piccolo.java:1400)     @ org.apache.xmlbeans.impl.piccolo.xml.piccolo.parse(piccolo.java:714)     @ org.apache.xmlbeans.impl.store.locale$saxloader.load(locale.java:3439)     @ org.apache.xmlbeans.impl.store.locale.parsetoxmlobject(locale.java:1270)     @ org.apache.xmlbeans.impl.store.locale.parsetoxmlobject(locale.java:1257)     @ org.apache.xmlbeans.impl.schema.schematypeloaderbase.parse(schematypeloaderbase.java:345)     @ org.openxmlformats.schemas.spreadsheetml.x2006.main.worksheetdocument$factory.parse(unknown source)     @ org.apache.poi.xssf.usermodel.xssfsheet.read(xssfsheet.java:188)     @ org.apache.poi.xssf.usermodel.xssfsheet.ondocumentread(xssfsheet.java:180)     @ org.apache.poi.xssf.usermodel.xssfworkbook.ondocumentread(xssfworkbook.java:300)     @ org.apache.poi.poixmldocument.load(poixmldocument.java:159)     @ org.apache.poi.xssf.usermodel.xssfworkbook.<init>(xssfworkbook.java:221)     @ testdoc.testdoc.main(testdoc.java:26) java result: 1 build successful (total time: 49 seconds) 

the line no 26 is

file excel = new file ("e:\\project\\rapid out\\"+filename+""+type+".xlsx");                 fileinputstream fis = new fileinputstream(excel);         line 26::   xssfworkbook wb = new xssfworkbook(fis);                 xssfsheet ws = wb.getsheet("sheet2"); 

instead of using inputstream, can try file:

xssfworkbook wb = new xssfworkbook(excel);

from poi guide

when opening workbook, either .xls hssfworkbook, or .xlsx xssfworkbook, workbook can loaded either file or inputstream. using file object allows lower memory consumption, while inputstream requires more memory has buffer whole file.


Comments

Popular posts from this blog

how to proxy from https to http with lighttpd -

android - Automated my builds -

python - Flask migration error -