|
@@ -438,13 +438,21 @@ public class ExcelUtils {
|
|
|
case BOOLEAN:
|
|
|
value = String.valueOf(cell.getBooleanCellValue());
|
|
|
break;
|
|
|
- case FORMULA:
|
|
|
- value = String.valueOf(cell.getNumericCellValue());
|
|
|
- break;
|
|
|
+ case FORMULA: {
|
|
|
+ //根据结果类型设置值
|
|
|
+ CellType cellType = cell.getCachedFormulaResultTypeEnum();
|
|
|
+ if (cellType == CellType.NUMERIC) value = String.valueOf(cell.getNumericCellValue());
|
|
|
+ else if (cellType == CellType.STRING) value = cell.getRichStringCellValue().toString();
|
|
|
+ else value = cell.getCellFormula();
|
|
|
+ }
|
|
|
+ break;
|
|
|
default:
|
|
|
break;
|
|
|
}
|
|
|
- } catch (Exception ignored) {
|
|
|
+ } catch (Exception e) {
|
|
|
+ LogPrintMgr.getInstance().printLogMsg(LogLevelFlag.LOG_ERROR, mBizType, mStrClassName
|
|
|
+ , String.format("excel单元格解释失败 error:%s", e)
|
|
|
+ );
|
|
|
}
|
|
|
return value == null ? "" : value.trim();
|
|
|
}
|