liurunyu
2025-06-19 37068a7c3f4a0c985a16a92ff64c361b6e1f17d5
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
package com.dy.pipIrrGlobal.excel;
 
import jakarta.servlet.http.HttpServletResponse;
 
import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;
 
/**
 * @author ZhuBaoMin
 * @date 2024-08-26 10:28
 * @LastEditTime 2024-08-26 10:28
 * @Description 设置excel下载响应头属性
 */
public class ExcelUtil {
    public static void setExcelRespProp(HttpServletResponse response, String rawFileName) throws UnsupportedEncodingException {
        String fileName = URLEncoder.encode(rawFileName, "UTF-8").replaceAll("\\+", "%20");
        response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
        response.setCharacterEncoding("utf-8");
        response.setHeader("Content-Disposition", "attachment;filename*=utf-8''" + fileName + ".xlsx");
    }
 
}