fix: Excel支持公式;错误提示增加文档链接

This commit is contained in:
junjie
2021-07-01 11:20:51 +08:00
parent fbba1e66bc
commit 162ac4d69a
4 changed files with 35 additions and 3 deletions

View File

@@ -975,6 +975,38 @@ public class DataSetTableService {
return "";
}
CellType cellTypeEnum = cell.getCellTypeEnum();
if (cellTypeEnum.equals(CellType.FORMULA)) {
try {
double d = cell.getNumericCellValue();
try {
Double value = new Double(d);
double eps = 1e-10;
if (value - Math.floor(value) < eps) {
if (cellType) {
tableFiled.setFieldType("LONG");
}
return value.longValue() + "";
} else {
if (cellType) {
tableFiled.setFieldType("DOUBLE");
}
NumberFormat nf = NumberFormat.getInstance();
nf.setGroupingUsed(false);
return nf.format(value);
}
} catch (Exception e) {
BigDecimal b = new BigDecimal(d);
return b.setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue() + "";
}
} catch (IllegalStateException e) {
String s = String.valueOf(cell.getRichStringCellValue());
if (cellType) {
tableFiled.setFieldType("TEXT");
tableFiled.setFieldSize(65533);
}
return s;
}
}
if (cellTypeEnum.equals(CellType.STRING)) {
if (cellType) {
tableFiled.setFieldType("TEXT");