Эх сурвалжийг харах

导入excel数组溢出BUG

wangliang 2 жил өмнө
parent
commit
053a9610bf

+ 8 - 6
themis-business/src/main/java/com/qmth/themis/business/util/ExcelUtil.java

@@ -104,12 +104,14 @@ public class ExcelUtil {
                                             field.set(o, map);
                                         }
                                     } else {
-                                        fields[j].setAccessible(true);
-                                        fields[j].set(o, obj);
-                                        Annotation annotation = fields[j].getAnnotation(NotNull.class);
-                                        ExcelNote note = fields[j].getAnnotation(ExcelNote.class);
-                                        if ((Objects.isNull(obj) || Objects.equals("", obj)) && Objects.nonNull(annotation)) {
-                                            excelErrorList.add(y, new ExcelError(i + 1, "excel第" + (y + 1) + "个sheet第" + (i + 1) + "行[" + note.value() + "]为空"));
+                                        if (j <= fields.length - 1) {
+                                            fields[j].setAccessible(true);
+                                            fields[j].set(o, obj);
+                                            Annotation annotation = fields[j].getAnnotation(NotNull.class);
+                                            ExcelNote note = fields[j].getAnnotation(ExcelNote.class);
+                                            if ((Objects.isNull(obj) || Objects.equals("", obj)) && Objects.nonNull(annotation)) {
+                                                excelErrorList.add(y, new ExcelError(i + 1, "excel第" + (y + 1) + "个sheet第" + (i + 1) + "行[" + note.value() + "]为空"));
+                                            }
                                         }
                                     }
                                 }