java - pagination of xlsx file to XSSFworkbook using apache POI -


right in code, reading xlsx file, xssfworkbook, , writing database. but, when size of xlsx file increases, causes outofmemory error. can not increase server size, or divide xlsx file pieces. tried loading workbook using file (instead of inputstream), didn't either.

i looking way read 10k rows @ time (instead of entire file @ once) , iteratively write workbook , database.

is there way apache poi?

poi contains called "eventmodel" designed purpose. it's mentioned in faq:

the ss eventmodel package api reading excel files without loading whole spreadsheet memory. require more knowledge on part of user, reduces memory consumption more tenfold. based on awt event model in combination sax. if need read-only access, best way it.

however, may want double check first if issue somewhere else. check out this item:

  1. i think poi using memory! can do? 1 comes quite lot, reason isn't might think. so, first thing check - what's source of problem? file? code? environment? or apache poi?

(if you're here, think it's apache poi. however, isn't! moderate laptop, decent not excessive heap size, standing start, can read or write file 100 columns , 100,000 rows in under couple of seconds, including time start jvm). apache poi ships few programs , few example programs, can used basic performance checks. testing file generation, class use in examples package, ssperformancetest. run ssperformancetest arguments of writing type (hssf, xssf or sxssf), number rows, number of columns, , if file should saved. if can't run 50,000 rows , 50 columns in hssf , sxssf in under 3 seconds, , xssf in under 10 seconds (and ideally 3 in less that!), problem environment. next, use example program tocsv try reading file in hssf or xssf. related xlsx2csv, uses sax parsing .xlsx. run against both problem file, , simple 1 generated ssperformancetest of same size. if slow, there apache poi problem how file being processed (poi makes assumptions might not right on files). if these tests fast, performance problems in code!


Comments

Popular posts from this blog

javascript - jQuery: Add class depending on URL in the best way -

caching - How to check if a url path exists in the service worker cache -

Redirect to a HTTPS version using .htaccess -