From 9ae8a3dd7d66f60ba7caf2bd341b685cf8bd8d4b Mon Sep 17 00:00:00 2001
From: zhanghua <314079846@qq.com>
Date: 星期三, 25 十月 2023 22:31:38 +0800
Subject: [PATCH] bug修改
---
ycl-common/src/main/java/com/ycl/utils/EasyExcelUtils.java | 13 ++++++++++++-
1 files changed, 12 insertions(+), 1 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 d479f54..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,12 +8,12 @@
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;
public class EasyExcelUtils {
-
/**
* @Description 瀵煎嚭
@@ -31,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