Bug 61082

Summary: getLastRowNum is misleading / unclear
Product: POI Reporter: Charles <shing10170>
Component: XSSFAssignee: POI Developers List <dev>
Severity: enhancement    
Priority: P2    
Version: 3.16-FINAL   
Target Milestone: ---   
Hardware: Macintosh   
OS: other   

Description Charles 2017-05-09 23:08:31 UTC
In a layman POV,
If I want to find to the first empty row(=getLastRowNum + 1), I would have called this method.
by empty, I mean the row appears to be empty (or in POI language, cell type BLANK) if you open the xlsx with excel. It doesnt matter whether the cell has been created or not.

The current problem is, if you have used a cell but then deleted the content (that means it is blank now), that cell was created in the xlsx and getLastRowNum will not consider that as the "last row".

I call that those created but blank or empty cells, "invisible cells"

1. upadate the javadoc to warn developer about this (because the current lastRow wording is misleading that people would think last row = last row that is not blank but current implementation is, last row = the largest row Number among the created cells in xlsx)

2. make a new method to do find the right "last row"
the new method could be called
getFirstBlankRowNum(column findWhichCol, row startAtRow)
,which is, find the first blank cell's rowNum or return the current getLastRowNum if all the cells were not blank

I know I am not a good explainer, please let me know if you want to know more or want to recruit someone to achieve this (I am looking for chances to do my-first-open-source-project)
Comment 1 Dominik Stadler 2017-09-28 13:15:45 UTC
We have updated the JavaDoc via r1809988 to explain this behavior better. 

Please note that for iterating over the actual valid rows/cells, you can use Sheet.rowIterator() and Row.cellIterator() which will leave out non-existing rows/cells, but still may return BLANK rows/cells.