| New file | 
 |  |  | 
 |  |  | 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"); | 
 |  |  |     } | 
 |  |  |  | 
 |  |  | } |