1、前言
在没有EasyExcel之前我们经常使用Apache的poi jar包进行excel的读写,配置起来比较麻烦,也比较消耗内存,阿里开源了EasyExcel,配置上简化了,在一定程度上简化了内存溢出问题。
2、引入jar包
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>easyexcel</artifactId>
<version>1.1.2-beta5</version>
</dependency>
3、读Excel
EasyExcel支持对实体类中的属性进行注解,方便后续进行读写操作。
//表示第0行,表头是id
@ExcelProperty(value = "id", index = 0)
3.1 Student实体类
public class Student extends BaseRowModel {
@ExcelProperty(value = "id", index = 0)
private Integer id;
@ExcelProperty(value = "姓名",index = 1)
private String name;
@ExcelProperty(value = "性别", index = 2)
private String sex;
@ExcelProperty(value = "年级", index = 3</