说明:本文章不是教EasyExcel的使用,使用教程是在官方文档很详细,本篇文章主要记录使用过程的一些坑
1. 使用时需要引入poi的包
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>easyexcel</artifactId>
<version>2.1.6</version>
</dependency>
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi</artifactId>
<version>3.17</version>
</dependency>
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi-ooxml</artifactId>
<version>3.17</version>
</dependency>
如果只依赖easyExcel的包,在调用生成excel的方法时会报错NoClassDefFoundError的错误,没找到poi的DefaultTempFileCreationStrategy。只针对当前的easyexce版本,其他版本不知道是不是这样。
2. 如果使用excel模板填充的问题
使用excel模板填充时,千万不要使用编译后的模板文件,因为编译过程会导致excel模板文件格式错误,导致报错,而且问题很难定位。