diff --git a/ruoyi-common/ruoyi-common-excel/src/main/java/org/dromara/common/excel/utils/ExcelUtil.java b/ruoyi-common/ruoyi-common-excel/src/main/java/org/dromara/common/excel/utils/ExcelUtil.java index 0e9569677..70ab31d9c 100644 --- a/ruoyi-common/ruoyi-common-excel/src/main/java/org/dromara/common/excel/utils/ExcelUtil.java +++ b/ruoyi-common/ruoyi-common-excel/src/main/java/org/dromara/common/excel/utils/ExcelUtil.java @@ -215,6 +215,9 @@ public class ExcelUtil { */ public static void exportTemplate(List data, String filename, String templatePath, HttpServletResponse response) { try { + if (CollUtil.isEmpty(data)) { + throw new IllegalArgumentException("数据为空"); + } resetResponse(filename, response); ServletOutputStream os = response.getOutputStream(); exportTemplate(data, templatePath, os); @@ -233,9 +236,6 @@ public class ExcelUtil { * @param os 输出流 */ public static void exportTemplate(List data, String templatePath, OutputStream os) { - if (CollUtil.isEmpty(data)) { - throw new IllegalArgumentException("数据为空"); - } ClassPathResource templateResource = new ClassPathResource(templatePath); ExcelWriter excelWriter = EasyExcel.write(os) .withTemplate(templateResource.getStream()) @@ -265,6 +265,9 @@ public class ExcelUtil { */ public static void exportTemplateMultiList(Map data, String filename, String templatePath, HttpServletResponse response) { try { + if (CollUtil.isEmpty(data)) { + throw new IllegalArgumentException("数据为空"); + } resetResponse(filename, response); ServletOutputStream os = response.getOutputStream(); exportTemplateMultiList(data, templatePath, os); @@ -285,6 +288,9 @@ public class ExcelUtil { */ public static void exportTemplateMultiSheet(List> data, String filename, String templatePath, HttpServletResponse response) { try { + if (CollUtil.isEmpty(data)) { + throw new IllegalArgumentException("数据为空"); + } resetResponse(filename, response); ServletOutputStream os = response.getOutputStream(); exportTemplateMultiSheet(data, templatePath, os); @@ -303,9 +309,6 @@ public class ExcelUtil { * @param os 输出流 */ public static void exportTemplateMultiList(Map data, String templatePath, OutputStream os) { - if (CollUtil.isEmpty(data)) { - throw new IllegalArgumentException("数据为空"); - } ClassPathResource templateResource = new ClassPathResource(templatePath); ExcelWriter excelWriter = EasyExcel.write(os) .withTemplate(templateResource.getStream()) @@ -337,9 +340,6 @@ public class ExcelUtil { * @param os 输出流 */ public static void exportTemplateMultiSheet(List> data, String templatePath, OutputStream os) { - if (CollUtil.isEmpty(data)) { - throw new IllegalArgumentException("数据为空"); - } ClassPathResource templateResource = new ClassPathResource(templatePath); ExcelWriter excelWriter = EasyExcel.write(os) .withTemplate(templateResource.getStream())