1.需要添加的依赖
<!-- Easyexcel -->
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>easyexcel</artifactId>
<version>3.0.5</version>
</dependency>
2.实体类
@Data
@ColumnWidth(10)//设置单元格的宽度
public class DataStatisticsVo {
@ExcelProperty(value = "ID",index = 0)//value为你的表头信息,index为下标
private String ID;
@ExcelProperty(value = "姓名",index = 1)
private String name;
@ExcelProperty(value = "年龄",index = 2)
private String age;
@ExcelProperty(value = "班级",index = 3)
private String clazz;
}
3.Controller层方法
@GetMapping("/exportExcel")
public void exportExcel(HttpServletResponse response) throws IOE