public static String getCellValue(Cell cell) {
int cellType = cell.getCellType();
String cellValue = "";
switch (cellType) {
case HSSFCell.CELL_TYPE_NUMERIC:
cellValue = String.valueOf(cell.getNumericCellValue());
break;
case HSSFCell.CELL_TYPE_FORMULA:
try {
cellValue = cell.getStringCellValue();
} catch (IllegalStateException e) {
cellValue = String.valueOf(cell.getNumericCellValue());
}
break;
default:
cellValue = cell.getStringCellValue();
}
return cellValue.trim();
}
java poi读取Excel里面含有公式的单元格的值
最新推荐文章于 2024-08-20 15:54:44 发布