4

I need to read large excel sheets using Java. The Excel sheet may be .xls or .xlsx. The sheet may have thousands of rows. I have to read all rows and insert that row in the database.

So basically read from Excel and write in database.

The APIs that I am considering are POI and JExcel API (After googling and reading some other related articles in SO).

But I am still not sure as to what is the most appropriate way of reading very large Excel sheets.

I don't want to have any memory issues later on.

Edit 1:

Also, from what I have searched so far it seems that JExcel does not support .xlsx formats.

Please suggest.

Jean-François Corbett
  • 37,420
  • 30
  • 139
  • 188
ajm
  • 12,863
  • 58
  • 163
  • 234
  • Take a look on this one: https://github.com/davidpelfree/sjxlsx – David Peleg Jan 19 '15 at 09:01
  • Notice that all classes in XSSF and HSSF package generally implement common interfaces, (e.g. WORKBOOK) and so on. If you are unsure what performs best, just make sure your business logic is written against the generic API classes and then have two implementations for the HSSF workbook constructor and for the XSSF constructor. – 99Sono Jan 18 '16 at 12:40

3 Answers3

3

We are reading Excel files of that size using Apache POI without problems.

jpstrube
  • 785
  • 1
  • 11
  • 27
  • 1
    Thanks for the comment. Won't there be any performance issues reading excel with say 50,000 rows? – ajm Feb 14 '12 at 07:38
  • Look [here](http://stackoverflow.com/questions/4897766/processing-large-xlsx-file-in-java) – jpstrube Feb 14 '12 at 07:42
3

If you only want to read the files then performance should be no problem with Apache POI as there are streaming APIs for read (think SAX vs. DOM).
See http://poi.apache.org/spreadsheet/index.html

Writing Excel files with POI would be a different scenario. But at least for .xlsxfiles there is an extension in beta to allow more efficient write operations with Apache POI (SXSSF).

Turismo
  • 2,064
  • 2
  • 16
  • 23
0

Try jExcel

See FAQ here.

I prefer it over Apache POI due to performance and usability.

Reading .xlsx is a limitation of jExcel library.

Azodious
  • 13,752
  • 1
  • 36
  • 71
  • Thanks for the answer. We will be reading the .xlsx files. So JExcel seems to be out of question then :( – ajm Feb 14 '12 at 07:46