Hi,
I am reading an Excel file but i am getting “Exception in thread “AWT-EventQueue-0” java.lang.NullPointerException” Error.
I have attached demo file . My First cell is having data and other cells are blank for first 2 rows,
Can you suggest me the best way to handle this exception as my File Structure is same.
Thanks.
Hi,
Hi,
This is the Code that i am Using for Reading the File
Code:
Workbook workbook = new Workbook();
FileInputStream fstream = new FileInputStream(Demo.xls);
workbook.open(fstream, FileFormatType.EXCEL97TO2003);
Worksheet worksheet = workbook.getWorksheets().getSheet(0);
Cells cells = worksheet.getCells();
System.out.print(workbook.getWorksheets().getActiveSheet().getName());
int num=cells.getMaxRow();
int num1=cells.getMaxColumn();
System.out.print(num);
System.out.print(num1);
for (int n=1;n<num;n++)
{ for(int nColIndex =0;nColIndex<=Last;nColIndex++)
{
System.out.println(cells.getCell( n,nColIndex).getValue());
Cell cell=cells.getCell(n,nColIndex);
}
}
workbook.save(“C:\OutPut.xls”,FileFormatType.EXCEL97TO2003);
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
Hi,
Thanks it is working Fine.
Hi,