Bug 29206 - NPE on HSSFSheet.getRow for blank rows
Summary: NPE on HSSFSheet.getRow for blank rows
Status: RESOLVED FIXED
Alias: None
Product: POI
Classification: Unclassified
Component: HSSF (show other bugs)
Version: 3.0-dev
Hardware: PC other
: P3 major (vote)
Target Milestone: ---
Assignee: POI Developers List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2004-05-25 16:27 UTC by Conrad Roche
Modified: 2007-01-16 01:36 UTC (History)
0 users



Attachments

Note You need to log in before you can comment on or make changes to this bug.
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