优化代码
This commit is contained in:
parent
6d07feaf46
commit
89840aa576
|
@ -1,5 +1,6 @@
|
|||
package net.maku.framework.common.utils;
|
||||
|
||||
import cn.hutool.core.util.URLUtil;
|
||||
import com.alibaba.excel.EasyExcel;
|
||||
import com.alibaba.excel.support.ExcelTypeEnum;
|
||||
import net.maku.framework.common.excel.ExcelDataListener;
|
||||
|
@ -11,8 +12,6 @@ import javax.servlet.http.HttpServletResponse;
|
|||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.IOException;
|
||||
import java.net.URLEncoder;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
|
@ -130,7 +129,7 @@ public class ExcelUtils {
|
|||
response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
|
||||
response.setCharacterEncoding("utf-8");
|
||||
// 这里URLEncoder.encode可以防止中文乱码 当然和easy excel没有关系
|
||||
String fileName = URLEncoder.encode(excelName, StandardCharsets.UTF_8).replaceAll("\\+", "%20");
|
||||
String fileName = URLUtil.encode(excelName).replaceAll("\\+", "%20");
|
||||
response.setHeader("Content-disposition", "attachment;filename*=utf-8''" + fileName + ".xlsx");
|
||||
EasyExcel.write(response.getOutputStream(), head).sheet(StringUtils.isBlank(sheetName) ? "sheet1" : sheetName).doWrite(data);
|
||||
} catch (IOException e) {
|
||||
|
|
Loading…
Reference in New Issue
Block a user