1.导入第三方依赖
maven依赖搜索引擎 https://mvnrepository.com/
<dependency>
<groupId>com.github.crab2died</groupId>
<artifactId>Excel4J</artifactId>
<version>2.1.4-Final</version>
</dependency>
2.实体类中使用@ExcelField注解
3.controller层
这就完成了一个小的demo,是不是超简单。。。
注:在项目中使用还需优化
注意事项:
1 使用 @ExcelField(title = “列名开头一定要小写”)
大写的报错:com.github.crab2died.exceptions.Excel4JException: java.beans.IntrospectionException: Can not get the getter or setter method
2.实体类的属性名一定要检查,有些情况下属性名开头大写的话也会报以上错误。