一、具体实现
import java.net.URLEncoder;
import com.alibaba.excel.EasyExcel;
List<实体> targets = xxx;
response.setContentType("application/vnd.ms-excel");
response.setCharacterEncoding("UTF-8");
String fileName= URLEncoder.encode("lkm","UTF-8");
response.setHeader("Content-disposition", "attachment;filename=" + fileName + ".xlsx");
response.setHeader("Access-Control-Expose-Headers","Content-disposition");
EasyExcel.write(response.getOutputStream(), 实体.class).autoCloseStream(Boolean.FALSE).sheet("sheet1").doWrite(targets);
二、实体
import com.alibaba.excel.annotation.ExcelIgnore;
import com.alibaba.excel.annotation.ExcelProperty;
import com.alibaba.excel.annotation.write.style.ColumnWidth;
import lombok.Data;
@Data
public class 实体{
    @ColumnWidth(25)
    @ExcelProperty(value="名字",index=0)
    private  String name;
    @ColumnWidth(25)
    @ExcelProperty(value="性别",index=1)
    private  String sex;
}
三、优化
1、@ExcelProperty
 注解中有三个参数value,index,converter分别代表列明,列序号,数据转换方式
用法:@ExcelProperty(value=“序号”,index=0)
2、@ColumnWith
 注解中有一个参数value代表列宽度
用法:@ColumnWidth(25)
3、@ContentFontStyle
 注解用于设置单元格内容字体格式
  4、@ContentLoopMerge
4、@ContentLoopMerge
 注解用于合并单元格,注解中有二个参数eachRow,columnExtend
5、@ContentRowHeight
 注解用于于设置行高,注解中有一个参数value代表行高,-1代表自动行高
6、@ContentStyle
 注解用于设置内容格式,参数众多百度;
7、@HeadFontStyle
 注解用于定制标题字体格式,参数众多百度;
8、@HeadRowHeight
 注解用于设置标题行行高,注解中有一个参数value代表行高,-1代表自动行高
9、@HeadStyle
 注解用于标题样式,参数众多百度;
10、@ExcelIgnore
 注解用于不将该字段转换成Excel
11、@ExcelIgnoreUnannotated
 注解放在实体方法上面,用于没有注解的字段都不转换


















![[QCA6174]QCA6174 DFS认证4.6.2.3 Channel Shutdown出现跳转之后在原始信道上有弱信号问题分析及解决方案](https://img-blog.csdnimg.cn/04a0969649e2425ba93439ef967e7e47.png)
