Im getting data from excel using HSSFWORKBOOK
. When there is not data in the cell, it shows the error as:
Exception in thread "main" java.lang.NullPointerException at ExecuteTestcase.Testcase_execute.main(Testcase_execute.java:47)
And my code is:
Sheet guru99Sheet = file.readExcel("D:\\SampleFramework.xls");
int rowCount = guru99Sheet.getLastRowNum()-guru99Sheet.getFirstRowNum();
for(int i=1;i<rowCount+1;i++) {
Row row = guru99Sheet.getRow(i);
//Check if the first cell contain a value, if yes, That means it is the new testcase name
if(row.getCell(0)==null) {
//Print testcase detail on console
System.out.println(row.getCell(1).toString()+"----"+ row.getCell(2).toString()+"----"+ row.getCell(3).toString()+"----"+ row.getCell(4).toString());
//Call perform function to perform operation on UI
operation.perform(allObjects, row.getCell(1).toString(), row.getCell(2).toString(), row.getCell(3).toString(), row.getCell(4).toString());
} else {
//Print the new testcase name when it started
System.out.println("New Testcase->"+row.getCell(0).toString() +" Started");
}
}
Please Help me out this.