zoukankan      html  css  js  c++  java
  • 使用POI导入Excel异常Cannot get a text value from a numeric cell 解决

    POI操作Excel时因为Excel数据Cell有不同的类型,会出现Cannot get a text value from a numeric cell的异常错误。

    异常原因:Excel数据Cell有不同的类型,当我们试图从一个数字类型的Cell读取出一个字符串并写入数据库时,就会出现Cannot get a text value from a numeric cell的异常错误。

    此异常常见于类似如下代码中:row.getCell(i).getStringCellValue();

    解决办法:先设置Cell的类型,将其他类型先转换成String类型

                        HSSFCell cell = row.getCell(j);
                        if (row.getCell(j)!=null) {
                            row.getCell(j).setCellType(Cell.CELL_TYPE_STRING);
                        }                    
                        String value = cell.getStringCellValue();

  • 相关阅读:
    顺时针
    true
    td
    确定删除
    on("submit",)
    float:right
    css中:hover空格
    磁盘恢复
    一、报表
    二、实践与视频解决方案
  • 原文地址:https://www.cnblogs.com/xijin-wu/p/5725716.html
Copyright © 2011-2022 走看看