How to use SXSSF POI to read a large spreadsheet

I am trying to read an xls file using SXSSF. I read about SXSSF but don't understand how to use it. Therefore, I am facing some problems.

Can someone help me with java code for reading large xls files (about 100,000 lines and 7-8 sheets).

(Edit comments)

Here is what I tried:

Workbook workBook = new SXSSFWorkbook(200); workBook = WorkbookFactory.create(inputStream); Sheet sheet = workBook.getSheetAt(0); int totalRows = sheet.getPhysicalNumberOfRows(); for (int i=0; i<totalRows; i++) { Row row = sheet.getRow(i); int totalCols = row.getPhysicalNumberOfCells(); for(int j=0; j<totalCols; j++) { Cell cell = row.getCell(j); } } 
+7
source share
1 answer

SXSSF is only for writing large excel (xlsx) files and not for reading.

To read large excel files, refer to the SAX event processing API for analyzing Apache POI: https://poi.apache.org/spreadsheet/how-to.html .

A very good working example is present at: https://svn.apache.org/repos/asf/poi/trunk/src/examples/src/org/apache/poi/xssf/eventusermodel/XLSX2CSV.java

+6
source

All Articles