Hi ,
Iam using poi to read excel sheet. Iam reading line by line of excel sheet using HssfUserModel.
Here is my code
int numberOfRows = sheet.getLastRowNum();
for (int i = 1; i <= numberOfRows; i++)
{
HSSFRow row = sheet.getRow(i);
// check whether row is null or not
if (row != null)
{
int numberOfCells = row.getLastCellNum();
for(int j=0;j <= numberOfCells;j++)
{
HSSFCell cell = row.getCell((short)j);
short cellNumber = cell.getCellNum();
//check whether cell is null or not
if(cell!=null)
{
if(cellNumber == myTradeConstants.scripCode_column_Number)
{
cell =row.getCell(myTradeConstants.scripCode_column_Number);
scripCode =cell.getStringCellValue();
System.out.println("scripCode:"+scripCode);
}
}
else
{
System.out.println("nocellValue");
break;
}
}
}
else
{
System.out.println("rowBreak");
break;
}
My Excel sheet is also having so many number of rows. But it is displaying only first row of the excel sheet. n displaying "nullpointerException".
why iam getting nullPointer Exception.
I want to check whether a cell is having data or not.
can anybody guide me in right dircection.
regards,
ramu.