huang
7 天以前 22e17b6db03ca58bc477a35ca067e55a09cffce7
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
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");
    }
}