|
@@ -17,6 +17,7 @@ import org.apache.poi.hssf.usermodel.HSSFDateUtil;
|
|
|
import org.apache.poi.ss.usermodel.*;
|
|
|
import org.apache.poi.xssf.usermodel.XSSFCell;
|
|
|
import org.apache.poi.xssf.usermodel.XSSFCellStyle;
|
|
|
+import org.apache.poi.xssf.usermodel.XSSFFormulaEvaluator;
|
|
|
import org.apache.poi.xssf.usermodel.XSSFRow;
|
|
|
import org.apache.poi.xssf.usermodel.XSSFSheet;
|
|
|
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
|
|
@@ -196,7 +197,13 @@ public class Excel {
|
|
|
|
|
|
// 2. 公式 CELL_TYPE_FORMULA
|
|
|
if (cell.getCellType() == CellType.FORMULA) {
|
|
|
- return cell.getStringCellValue();
|
|
|
+ FormulaEvaluator formulaEvaluator = new XSSFFormulaEvaluator((XSSFWorkbook) book);
|
|
|
+ CellValue evaluate = formulaEvaluator.evaluate(cell);
|
|
|
+ String format = evaluate.formatAsString();
|
|
|
+ if (format.contains("E")) {
|
|
|
+ format = new BigDecimal(format+"").toString();
|
|
|
+ }
|
|
|
+ return format;
|
|
|
}
|
|
|
|
|
|
// 4. 布尔值 CELL_TYPE_BOOLEAN
|