Free Support Forum -

Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException

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.



Could you give us your sample code to reproduce the issue on our end.
I just tried to read and write (Save As) your file with the attached version and it works fine.

Sample code:
Workbook book = new Workbook();“Demo.xls”);“outDemo.xls”);
Kindly try the attached version, if you still find the issue paste your sample code here, we will check your issue soon.

Thank you.

This is the Code that i am Using for Reading the File


Workbook workbook = new Workbook();
FileInputStream fstream = new FileInputStream(Demo.xls);, FileFormatType.EXCEL97TO2003);
Worksheet worksheet = workbook.getWorksheets().getSheet(0);
Cells cells = worksheet.getCells();
int num=cells.getMaxRow();
int num1=cells.getMaxColumn();
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);
} catch (IOException e) {
// TODO Auto-generated catch block


Please try the latest fix/version that I attached in my previous reply. I have tested, it works fine with your code.

Thank you.

Thanks it is working Fine.


Good to know that your issue is resolved now.

Thank you and have a nice day!