POI操作Excel时Cannot get a text value from a numeric formula cell非法参数异常

ExcelSheet = ExcelBook.getSheet(SheetName);

Cell = ExcelSheet.getRow(RowNum).getCell(ColNum);

String cellData = Cell.getStringCellValue();

报非法参数错误。

String无法获取一个数值类型

修改代码

String cellData = null;
ExcelSheet = ExcelBook.getSheet(SheetName);
Cell = ExcelSheet.getRow(RowNum).getCell(ColNum);
if (Cell != null) {
  Cell.setCellType(Cell.CELL_TYPE_STRING);
      cellData = Cell.getStringCellValue();
}

即可。

原文地址:https://www.cnblogs.com/huyufan/p/6645217.html