POI HSSF not iterating full set of rows

43 views Asked by At

Cannot iterate the full extent of rows in my XLS spreadsheet. The code {sheet.getPhysicalNumberOfRows} returns 33492 without raising exception, but there are about 43,000 rows??.

If I supply the right number manually the loop executes without complaint.

It must be simple answer but I cannot find one anywhere. can somebody help?

    try {
        POIFSFileSystem fs = new POIFSFileSystem(new 
        FileInputStream(fileLocation));
        HSSFWorkbook wb = new HSSFWorkbook(fs);
        HSSFSheet sheet = wb.getSheetAt(0);
        HSSFRow row;
        HSSFCell cell;

        int rows; // No of rows
        rows = sheet.getPhysicalNumberOfRows(); //Gets => 33494

        int cols = 1; // No of columns
        int tmp = 0;

        for (int r = 0; r < rows; r++) {
            row = sheet.getRow(r);
            if (row != null) {
                cell = row.getCell(0);
                if (cell != null) {
                    System.out.println("Line number: " + r  " = " + cell);
                }
            }
        }

    } catch(Exception ioe) {
        ioe.printStackTrace();
    }
0

There are 0 answers