Bug 39921

Summary: getLastRowNum broken for empty sheets
Product: POI Reporter: Andreas Goetz <cpuidle>
Component: HSSFAssignee: POI Developers List <dev>
Status: RESOLVED DUPLICATE    
Severity: normal    
Priority: P2    
Version: 2.5-FINAL   
Target Milestone: ---   
Hardware: Other   
OS: other   

Description Andreas Goetz 2006-06-28 15:42:13 UTC
We're seing excel sheets that return getLastRowNum()=0 but do not allow reading
row 0:

for (int i = sheet.getFirstRowNum(); i <= sheet.getLastRowNum(); i++) HSSFRow
row = getRow(sheet, i);
-> NullPointerException when using getRow.

Alternatively using the iterator interface this error can be avoided:

for (Iterator iter = sheet.rowIterator(); iter.hasNext();) 			HSSFRow row =
(HSSFRow) iter.next();

Expected behaviour would be getLastRowNum() returning -1 instead of 0.
Comment 1 Andreas Goetz 2006-06-28 15:43:01 UTC
I believe this issue may be related to bug 30635 but decided to open a new one
as 30635 didn't get updated since 2004.
Comment 2 Andreas Goetz 2006-09-05 13:26:50 UTC

*** This bug has been marked as a duplicate of 30635 ***