前言
talk is cheap, show you the code.
第一步:定义Easyexcel导出的接口类 以及 参数类
接口类定义
public interface ExcelExporter {
/**
* 直接输出到网络流
*/
default void webExport(HttpServletResponse response,
ExportParam param) {
//try-with-resource
try (OutputStream out = response.getOutputStream()) {
//设置输出流为web
param.setOutputStream(out);
// 这里注意使用swagger 会导致各种问题,请直接用浏览器或者用postman
response.setContentType("application/vnd.ms-excel");
response.setCharacterEncoding(StandardCharsets.UTF_8.name());
String fileName = param.getMetaDataEnum().getFileName();
if (StringUtils.is