xml
<!-- easyexcel-->
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>easyexcel</artifactId>
<version>3.1.1</version>
<exclusions>
<exclusion>
<groupId>org.apache.poi</groupId>
<artifactId>poi</artifactId>
</exclusion>
<exclusion>
<groupId>org.apache.poi</groupId>
<artifactId>poi-ooxml</artifactId>
</exclusion>
<exclusion>
<groupId>org.apache.poi</groupId>
<artifactId>poi-ooxml-schemas</artifactId>
</exclusion>
</exclusions>
</dependency>
<!-- 不排除的话用下面这个 easyexcel-->
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>easyexcel</artifactId>
<version>3.1.1</version>
</dependency>
我这里是因为还引入了poi的依赖冲突了,所以需要排除一些。二选一
java
@Test
public void simpleReadDemo1() {
List<String> list = new ArrayList<>();
EasyExcel.read("D:\\test2.xlsx", HistoryPoDemo.class, new PageReadListener<HistoryPoDemo>(dataList -> {
for (HistoryPoDemo demoData : dataList) {
}
})).sheet().doRead();
System.out.print(list);
System.out.println(list.size());
}
java
@Data
@AllArgsConstructor
@NoArgsConstructor
public class HistoryPoDemo {
private String item1;
private String item2;
private Long item3;
private String ifOut;
}