From fbd31387721424c65b173cbb23b03202f3e7dce6 Mon Sep 17 00:00:00 2001 From: zhoushihao <zsh19950802@163.com> Date: 星期一, 12 五月 2025 21:13:47 +0800 Subject: [PATCH] Merge remote-tracking branch 'origin/master' --- hangzhoumesParent/common/servicebase/src/main/java/com/mes/utils/excel/ExcelUtil.java | 19 +++++++++++++++++++ 1 files changed, 19 insertions(+), 0 deletions(-) diff --git a/hangzhoumesParent/common/servicebase/src/main/java/com/mes/utils/excel/ExcelUtil.java b/hangzhoumesParent/common/servicebase/src/main/java/com/mes/utils/excel/ExcelUtil.java new file mode 100644 index 0000000..b8559ef --- /dev/null +++ b/hangzhoumesParent/common/servicebase/src/main/java/com/mes/utils/excel/ExcelUtil.java @@ -0,0 +1,19 @@ +package com.mes.utils.excel; + +import javax.servlet.http.HttpServletResponse; +import java.io.UnsupportedEncodingException; +import java.net.URLEncoder; + +/** + * @Author : zhoush + * @Date: 2025/5/12 17:03 + * @Description: + */ +public class ExcelUtil { + public static void setExcelResponseProp(HttpServletResponse response, String rawFileName) throws UnsupportedEncodingException { + response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"); + response.setCharacterEncoding("utf-8"); + String fileName = URLEncoder.encode(rawFileName, "UTF-8").replaceAll("\\+", "%20"); + response.setHeader("Content-disposition", "attachment;filename*=utf-8''" + fileName + ".xlsx"); + } +} -- Gitblit v1.8.0