您的位置:首页 > 产品设计 > UI/UE

Cannot get a text value from a numeric cell

2014-12-04 10:45 441 查看
在使用poi读取excel时报错为:Cannot get a text value from a numeric cell

刚开始的写法为:

Cell cell = row.getCell(j);

if (cell == null) {

continue;

}

switch(cell.getCellType()){

case Cell.CELL_TYPE_BOOLEAN :

cell.getBooleanCellValue();

case Cell.CELL_TYPE_STRING :

cell.getStringCellValue();

case Cell.CELL_TYPE_NUMERIC:

cell.getNumericCellValue();

}

后改为:

Cell cell = row.getCell(j);

if (cell == null) {

continue;

}

cell.setCellType(Cell.CELL_TYPE_STRING);

str = cell.getStringCellValue();

就不报错了。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: