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;
}
相关推荐
bug攻城狮6 分钟前
Spring Boot Banner
java·spring boot·后端
MadPrinter33 分钟前
SpringBoot学习日记 Day11:博客系统核心功能深度开发
java·spring boot·后端·学习·spring·mybatis
Java水解2 小时前
Spring Boot 启动流程详解
spring boot·后端
网安Ruler2 小时前
第49天:Web开发-JavaEE应用&SpringBoot栈&模版注入&Thymeleaf&Freemarker&Velocity
java·spring boot·后端
奔跑吧邓邓子3 小时前
【Java实战㉟】Spring Boot与MyBatis:数据库交互的进阶之旅
java·spring boot·实战·mybatis·数据库交互
kong@react4 小时前
springboot项目详细配置rabbitmq及使用rabbitmq完成评论功能
spring boot·rabbitmq·java-rabbitmq
九转苍翎5 小时前
星辰诞愿——生日快乐
spring boot
JIngJaneIL5 小时前
汽车租赁|基于Java+vue的汽车租赁系统(源码+数据库+文档)
java·vue.js·spring boot·汽车·论文·毕设·汽车租赁系统
聆风吟º6 小时前
【Spring Boot 报错已解决】Web server failed to start. Port 8080 was already in use.
spring boot·笔记·技术干货
一叶飘零_sweeeet6 小时前
SpringBoot 数据脱敏实战: 构建企业级敏感信息保护体系
java·spring boot·数据安全