我有一个带有以下虚拟数据的 Excel 表
UID ROLL NO. NAME
16004 1 fgh
16005 2 fhg
16006 3 dfg
16018 4 dfgdf
16029 5 sd
我编写了一个代码,它从 excel 中读取数据并将其插入数据库。阅读时,我只能阅读第一列。在读取其他列的值时我得到空值。
这是代码。
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)
有人可以帮我吗?