Browse Source

excel 导入数字不需要格式化 ,导入允许列和属性个数不一致

tags/v2.1
RuoYi 4 years ago
parent
commit
40696a10e3
  1. 15
      ruoyi-common/ruoyi-common-core/src/main/java/com/ruoyi/common/core/utils/poi/ExcelUtil.java
  2. 4
      ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/utils/DictUtils.java

15
ruoyi-common/ruoyi-common-core/src/main/java/com/ruoyi/common/core/utils/poi/ExcelUtil.java

@ -6,7 +6,6 @@ import java.io.OutputStream; @@ -6,7 +6,6 @@ import java.io.OutputStream;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.math.BigDecimal;
import java.text.DecimalFormat;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Comparator;
@ -194,7 +193,10 @@ public class ExcelUtil<T> @@ -194,7 +193,10 @@ public class ExcelUtil<T>
// 设置类的私有字段属性可访问.
field.setAccessible(true);
Integer column = cellMap.get(attr.name());
fieldsMap.put(column, field);
if (column != null)
{
fieldsMap.put(column, field);
}
}
}
for (int i = 1; i < rows; i++)
@ -829,14 +831,7 @@ public class ExcelUtil<T> @@ -829,14 +831,7 @@ public class ExcelUtil<T>
}
else
{
if ((Double) val % 1 > 0)
{
val = new DecimalFormat("0.00").format(val);
}
else
{
val = new DecimalFormat("0").format(val);
}
val = new BigDecimal(val.toString()); // 浮点格式处理
}
}
else if (cell.getCellTypeEnum() == CellType.STRING)

4
ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/utils/DictUtils.java

@ -37,8 +37,8 @@ public class DictUtils @@ -37,8 +37,8 @@ public class DictUtils
Object cacheObj = SpringUtils.getBean(RedisService.class).getCacheObject(getCacheKey(key));
if (StringUtils.isNotNull(cacheObj))
{
List<SysDictData> DictDatas = StringUtils.cast(cacheObj);
return DictDatas;
List<SysDictData> dictDatas = StringUtils.cast(cacheObj);
return dictDatas;
}
return null;
}

Loading…
Cancel
Save