Unable to read cell value from excel sheet using HSSF workbook in Java

208 views Asked by At

I have an excel sheet with following dummy data

UID     ROLL NO.    NAME
16004   1          fgh
16005   2          fhg
16006   3          dfg
16018   4          dfgdf
16029   5          sd

I have written a code that reads the data from excel and inserts that into database. While reading, I am able to read only the first column. I am getting null while reading the values of other columns.

Here is the code.

cell = row.getCell(0);
System.out.println(cell.getNumericCellValue());//I am able to print this

cell = row.getCell(1);
System.out.println(cell);// here i am getting null
System.out.println(cell.getStringCellValue());// NUll pointer exception
                                              // Even get numeric value 
                                  //doesn't work as the cell itself is null.

cell = row.getCell(2); 
System.out.println(cell.getStringCellValue());//Here also I am getting Null 
                    //pointer exception (if the previous code is commented)

Can some one help me out?

0

There are 0 answers