Bug 29206

Summary: NPE on HSSFSheet.getRow for blank rows
Product: POI Reporter: Conrad Roche <new_connie>
Component: HSSFAssignee: POI Developers List <dev>
Status: RESOLVED FIXED    
Severity: major    
Priority: P3    
Version: 3.0-dev   
Target Milestone: ---   
Hardware: PC   
OS: other   

Description Conrad Roche 2004-05-25 16:27:46 UTC
for(int i = 1; i < 400; i++) {
   HSSFRow row = sheet.getRow(i);  //this line fails for empty row
   HSSFCell cell = row.getCell((short)0);
   value = cell.getStringCellValue();
   System.out.println("" + i + "\t"+ value);
}

The above code breaks when it encounters a blank line. I get a null pointer
exception on the line following the last data line -
java.lang.NullPointerException
	at org.apache.poi.hssf.usermodel.HSSFRow.<init>(HSSFRow.java:123)
	at org.apache.poi.hssf.usermodel.HSSFSheet.getRow(HSSFSheet.java:311)
	at accesslog.ReadXls.main(ReadXls.java:38)
Exception in thread "main" 

I'm using the dev version of POI (I got it from the CVS on 3rd May, so its a bit
old).

cheers
Conrad
Comment 1 Avik Sengupta 2007-01-16 01:36:03 UTC
Works as of 12Jan2007, Testcase added. 
http://issues.apache.org/bugzilla/show_bug.cgi?id=41366