diff --git a/ruoyi-common/src/main/java/com/ruoyi/common/utils/poi/ExcelUtil.java b/ruoyi-common/src/main/java/com/ruoyi/common/utils/poi/ExcelUtil.java index 7fb2c65a1a..b65f049024 100644 --- a/ruoyi-common/src/main/java/com/ruoyi/common/utils/poi/ExcelUtil.java +++ b/ruoyi-common/src/main/java/com/ruoyi/common/utils/poi/ExcelUtil.java @@ -423,7 +423,7 @@ public class ExcelUtil Object val = this.getCellValue(row, entry.getKey()); // 如果不存在实例则新建. - entity = (entity == null ? clazz.newInstance() : entity); + entity = (entity == null ? clazz.getDeclaredConstructor().newInstance() : entity); // 从map中得到对应列的field. Field field = (Field) entry.getValue()[0]; Excel attr = (Excel) entry.getValue()[1]; @@ -1438,7 +1438,7 @@ public class ExcelUtil { try { - Object instance = excel.handler().newInstance(); + Object instance = excel.handler().getDeclaredConstructor().newInstance(); Method formatMethod = excel.handler().getMethod("format", new Class[] { Object.class, String[].class, Cell.class, Workbook.class }); value = formatMethod.invoke(instance, value, excel.args(), cell, this.wb); }