easyexcel导出文件乱码
时间: 2023-12-17 15:29:01 浏览: 432
解决ecside导出文件乱码问题
4星 · 用户满意度95%
```java
// 通过EasyExcel导出文件时出现乱码可以尝试设置编码格式为UTF-8
ExcelWriter excelWriter = EasyExcel.write(response.getOutputStream(), YourDataModel.class)
.excelType(ExcelTypeEnum.XLSX)
.build();
excelWriter.write(data, EasyExcel.writerSheet("sheetName").build());
excelWriter.finish();
```
```java
// 另外,也可以在response设置响应头的编码格式为UTF-8
response.setCharacterEncoding("UTF-8");
response.setContentType("application/vnd.ms-excel");
response.setHeader("Content-disposition", "attachment;filename=" + URLEncoder.encode("fileName.xlsx", "UTF-8"));
```
阅读全文