Quellcode durchsuchen

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

RuoYi vor 5 Jahren
Ursprung
Commit
40696a10e3

+ 5 - 10
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 6
 import java.lang.reflect.Field;
7 7
 import java.lang.reflect.Method;
8 8
 import java.math.BigDecimal;
9
-import java.text.DecimalFormat;
10 9
 import java.util.ArrayList;
11 10
 import java.util.Arrays;
12 11
 import java.util.Comparator;
@@ -194,7 +193,10 @@ public class ExcelUtil<T>
194 193
                     // 设置类的私有字段属性可访问.
195 194
                     field.setAccessible(true);
196 195
                     Integer column = cellMap.get(attr.name());
197
-                    fieldsMap.put(column, field);
196
+                    if (column != null)
197
+                    {
198
+                        fieldsMap.put(column, field);
199
+                    }
198 200
                 }
199 201
             }
200 202
             for (int i = 1; i < rows; i++)
@@ -829,14 +831,7 @@ public class ExcelUtil<T>
829 831
                     }
830 832
                     else
831 833
                     {
832
-                        if ((Double) val % 1 > 0)
833
-                        {
834
-                            val = new DecimalFormat("0.00").format(val);
835
-                        }
836
-                        else
837
-                        {
838
-                            val = new DecimalFormat("0").format(val);
839
-                        }
834
+                        val = new BigDecimal(val.toString()); // 浮点格式处理
840 835
                     }
841 836
                 }
842 837
                 else if (cell.getCellTypeEnum() == CellType.STRING)

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

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