From 6a742e1d1bb1fc8c7809ab993367c85daf7a54b4 Mon Sep 17 00:00:00 2001 From: RuoYi Date: Sat, 19 Aug 2023 15:43:57 +0800 Subject: [PATCH] =?UTF-8?q?Excel=E5=AF=BC=E5=85=A5=E6=95=B0=E6=8D=AE?= =?UTF-8?q?=E4=B8=B4=E6=97=B6=E6=96=87=E4=BB=B6=E6=97=A0=E6=B3=95=E5=88=A0?= =?UTF-8?q?=E9=99=A4=E9=97=AE=E9=A2=98(I7KIXX)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/ruoyi/common/utils/poi/ExcelUtil.java | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) 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 bafb9c07..349ee75d 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 @@ -288,9 +288,23 @@ public class ExcelUtil * @param is 输入流 * @return 转换后集合 */ - public List importExcel(InputStream is) throws Exception + public List importExcel(InputStream is) { - return importExcel(is, 0); + List list = null; + try + { + list = importExcel(is, 0); + } + catch (Exception e) + { + log.error("导入Excel异常{}", e.getMessage()); + throw new UtilException(e.getMessage()); + } + finally + { + IOUtils.closeQuietly(is); + } + return list; } /** @@ -336,7 +350,6 @@ public class ExcelUtil } // 获取最后一个非空行的行下标,比如总行数为n,则返回的为n-1 int rows = sheet.getLastRowNum(); - if (rows > 0) { // 定义一个map用于存放excel列的序号和field.