From 7ef4892f9f24f941aca37e6b3991b808a0aca619 Mon Sep 17 00:00:00 2001
From: zhanghua <314079846@qq.com>
Date: 星期五, 08 九月 2023 11:16:35 +0800
Subject: [PATCH] 优化
---
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