报错,没有处理,没有错误拦截页面,从页面上获得的信息是404

结果大佬帮我看生产日志,发现是这个错误Excel导入异常Cannot get a text value from a numeric cell解决
java.lang.IllegalStateException: Cannot get a text value from a numeric cell

Excel文档中手机号码不是文本格式

解决

POI操作Excel时偶尔会出现Cannot get a text value from a numeric cell的异常错误。

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

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

解决办法:先设置Cell的类型,然后就可以把纯数字作为String类型读进来了:

if(row.getCell(0)!=null){
          row.getCell(0).setCellType(Cell.CELL_TYPE_STRING);
          stuUser.setPhone(row.getCell(0).getStringCellValue());
     }
View Code

https://www.cnblogs.com/diaoniwa/p/6945291.html

 

报错点5,手机号 

 

 

row.getCell(5).setCellType(Cell.CELL_TYPE_STRING);
String telephone = row.getCell(5).getStringCellValue().trim();
这解决不了问题

https://bbs.csdn.net/topics/390190863
取单元格内数据时,先判断一下数据类型即可。
Sheet sheet1 = wb.getSheetAt(0);
    for (Row row : sheet1) {
        for (Cell cell : row) {
            CellReference cellRef new CellReference(row.getRowNum(), cell.getColumnIndex());
            System.out.print(cellRef.formatAsString());
            System.out.print(" - ");
 
            switch (cell.getCellType()) {
                case Cell.CELL_TYPE_STRING:
                    System.out.println(cell.getRichStringCellValue().getString());
                    break;
                case Cell.CELL_TYPE_NUMERIC:
                    if (DateUtil.isCellDateFormatted(cell)) {
                        System.out.println(cell.getDateCellValue());
                    } else {
                        System.out.println(cell.getNumericCellValue());
                    }
                    break;
                case Cell.CELL_TYPE_BOOLEAN:
                    System.out.println(cell.getBooleanCellValue());
                    break;
                case Cell.CELL_TYPE_FORMULA:
                    System.out.println(cell.getCellFormula());
                    break;
                default:
                    System.out.println();
            }
        }
    }
View Code

 

 

最终解决方法POI读取Excel 各种特殊数字和类型的转换。取值带一个E

https://blog.csdn.net/johnstrive/article/details/8393541
https://blog.csdn.net/qq_36125733/article/details/75161728

String telephone = new String();
            switch (row.getCell(5).getCellType()) {
                case Cell.CELL_TYPE_STRING:
                    telephone = row.getCell(5).getStringCellValue().trim();
                    break;
                case Cell.CELL_TYPE_NUMERIC:
                    telephone = new DecimalFormat("#").format(row.getCell(5).getNumericCellValue());
                    break;
                default:
                    break;
            }
View Code