From dfea866e55c725bd601ff84c92dff30f83057571 Mon Sep 17 00:00:00 2001
From: zhanghua <314079846@qq.com>
Date: 星期四, 30 三月 2023 19:56:59 +0800
Subject: [PATCH] Merge branch 'master' of http://42.193.1.25:9521/r/sccg_server
---
ycl-common/src/main/java/com/ycl/utils/EasyExcelUtils.java | 12 ++++++++++++
1 files changed, 12 insertions(+), 0 deletions(-)
diff --git a/ycl-common/src/main/java/com/ycl/utils/EasyExcelUtils.java b/ycl-common/src/main/java/com/ycl/utils/EasyExcelUtils.java
index 50156d9..4d9f1b7 100644
--- a/ycl-common/src/main/java/com/ycl/utils/EasyExcelUtils.java
+++ b/ycl-common/src/main/java/com/ycl/utils/EasyExcelUtils.java
@@ -8,6 +8,7 @@
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
+import java.net.URLEncoder;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.Collection;
@@ -30,6 +31,17 @@
}
@SneakyThrows
+ public static void export1(HttpServletResponse response, String sheetName, Class className, Collection<?> collection, String fileName) {
+ fileName = URLEncoder.encode(fileName, "UTF-8");
+ response.setContentType("application/vnd.ms-excel");
+ response.setCharacterEncoding("utf-8");
+ response.setHeader("Content-disposition", "attachment;filename*=utf-8''" + LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd")) + fileName + ".xlsx");
+ EasyExcel.write(response.getOutputStream(), className)
+ .sheet(sheetName)
+ .doWrite(collection);
+ }
+
+ @SneakyThrows
public static void importDepartFile(MultipartFile file) throws IOException {
EasyExcel.read(file.getInputStream())
.head(UmsDepartDto.class)
--
Gitblit v1.8.0