Browse Source

修改demo safari浏览器中文乱码的bug

developing
Jiaju Zhuang 4 years ago
parent
commit
ce69683a7a
  1. 4
      src/test/java/com/alibaba/easyexcel/test/demo/web/WebTest.java

4
src/test/java/com/alibaba/easyexcel/test/demo/web/WebTest.java

@ -46,8 +46,8 @@ public class WebTest {
response.setContentType("application/vnd.ms-excel");
response.setCharacterEncoding("utf-8");
// 这里URLEncoder.encode可以防止中文乱码 当然和easyexcel没有关系
String fileName = URLEncoder.encode("测试", "UTF-8");
response.setHeader("Content-disposition", "attachment;filename=" + fileName + ".xlsx");
String fileName = URLEncoder.encode("测试", "UTF-8").replaceAll("\\+", "%20");
response.setHeader("Content-disposition", "attachment;filename*=utf-8''" + fileName + ".xlsx");
EasyExcel.write(response.getOutputStream(), DownloadData.class).sheet("模板").doWrite(data());
}

Loading…
Cancel
Save