When there are no rows created in the sheet, sheet.getLastRowNum() returns 0 but when there is 1 row created, sheet.getLastRowNum() also returns 0. Shouldn't sheet.getLastRowNum() return -1 for sheet that has no rows? This is causing issues when you try to create a new row based on the last row number. Due to the above issue, the first row that gets created will start from the 2nd row instead of the very top. private Row row; public void createRow() { row = sheet.createRow(sheet.getLastRowNum() + 1); }
This would affect other methods as well, e.g. Sheet.getFirstRowNum(). Row.getFirstCellNum() and Row.getLastCellNum() already return -1 in this case.
With r1871589 we now return -1 in all getFirstRow/getFirstColumn calls in all three implementations (HSSF, XSSF, SXSSF) and thus should be consistent in how this is handled.