EasyExcel:简单读取本地文件

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;
}
相关推荐
摇滚侠1 天前
Spring Boot3零基础教程,Spring Boot 应用打包成 exe 可执行文件,笔记91 笔记92 笔记93
linux·spring boot·笔记
lang201509281 天前
Spring Boot日志配置完全指南
java·spring boot·单元测试
故事不长丨1 天前
【Java SpringBoot+Vue 实现视频文件上传与存储】
java·javascript·spring boot·vscode·后端·vue·intellij-idea
星梦清河1 天前
Redis(四):缓存击穿及其解决方案(SpringBoot+mybatis-plus)
spring boot·redis·缓存
FAFU_kyp1 天前
WebMvcConfig 和 WebSecurityConfig 详解
spring boot·java-ee
往事随风去1 天前
虚拟线程在Spring Boot中的正确使用方式
spring boot
麦兜*1 天前
Spring Boot 应用 Docker 监控:Prometheus + Grafana 全方位监控
spring boot·后端·spring cloud·docker·prometheus
L.EscaRC1 天前
Redisson在Spring Boot中的高并发应用解析
java·spring boot·后端
Naylor1 天前
玩转kafka
spring boot·kafka
摇滚侠1 天前
Spring Boot3零基础教程,StreamAPI 介绍,笔记98
java·spring boot·笔记