From ab06f7043e4192556c4d9881b0430bcb6cc75f50 Mon Sep 17 00:00:00 2001
From: whywhyo <1511349576@qq.com>
Date: 星期三, 03 五月 2023 23:28:02 +0800
Subject: [PATCH] 完成家根网

---
 ruoyi-common/src/main/java/com/ruoyi/common/utils/poi/ExcelUtil.java |   36 ++++++++++++++++++++++++++++++++++++
 1 files changed, 36 insertions(+), 0 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 755292b..0a48f37 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
@@ -24,6 +24,8 @@
 import java.util.UUID;
 import java.util.stream.Collectors;
 import javax.servlet.http.HttpServletResponse;
+
+import com.alibaba.excel.EasyExcel;
 import org.apache.commons.lang3.ArrayUtils;
 import org.apache.commons.lang3.RegExUtils;
 import org.apache.commons.lang3.reflect.FieldUtils;
@@ -1731,4 +1733,38 @@
         }
         return method;
     }
+
+
+    /**
+     * 瀵筫xcel琛ㄥ崟榛樿绗竴涓储寮曞悕杞崲鎴恖ist锛圗asyExcel锛�
+     *
+     * @param is 杈撳叆娴�
+     * @return 杞崲鍚庨泦鍚�
+     */
+    public List<T> importEasyExcel(InputStream is) throws Exception
+    {
+        return EasyExcel.read(is).head(clazz).sheet().doReadSync();
+    }
+
+    /**
+     * 瀵筶ist鏁版嵁婧愬皢鍏堕噷闈㈢殑鏁版嵁瀵煎叆鍒癳xcel琛ㄥ崟锛圗asyExcel锛�
+     *
+     * @param list 瀵煎嚭鏁版嵁闆嗗悎
+     * @param sheetName 宸ヤ綔琛ㄧ殑鍚嶇О
+     * @return 缁撴灉
+     */
+    public void exportEasyExcel(HttpServletResponse response, List<T> list, String sheetName)
+    {
+        try
+        {
+            EasyExcel.write(response.getOutputStream(), clazz).sheet(sheetName).doWrite(list);
+        }
+        catch (IOException e)
+        {
+            log.error("瀵煎嚭EasyExcel寮傚父{}", e.getMessage());
+        }
+    }
+
+
+
 }

--
Gitblit v1.9.1