Bug 63749 - sheet.getLastRowNum() returns 0 when there are no rows in the sheet
Summary: sheet.getLastRowNum() returns 0 when there are no rows in the sheet
Status: NEW
Alias: None
Product: POI
Classification: Unclassified
Component: POI Overall (show other bugs)
Version: 3.17-FINAL
Hardware: Macintosh
: P2 normal (vote)
Target Milestone: ---
Assignee: POI Developers List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2019-09-15 10:11 UTC by Nathan
Modified: 2019-09-15 10:11 UTC (History)
0 users



Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Nathan 2019-09-15 10:11:59 UTC
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);
    }