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;
}
相关推荐
泉城老铁3 小时前
Spring Boot对接抖音获取H5直播链接详细指南
spring boot·后端·架构
后端小张1 天前
基于飞算AI的图书管理系统设计与实现
spring boot
考虑考虑2 天前
Jpa使用union all
java·spring boot·后端
阿杆2 天前
同事嫌参数校验太丑,我直接掏出了更优雅的 SpEL Validator
java·spring boot·后端
昵称为空C3 天前
SpringBoot3 http接口调用新方式RestClient + @HttpExchange像使用Feign一样调用
spring boot·后端
麦兜*3 天前
MongoDB Atlas 云数据库实战:从零搭建全球多节点集群
java·数据库·spring boot·mongodb·spring·spring cloud
麦兜*3 天前
MongoDB 在物联网(IoT)中的应用:海量时序数据处理方案
java·数据库·spring boot·物联网·mongodb·spring
汤姆yu3 天前
基于springboot的毕业旅游一站式定制系统
spring boot·后端·旅游
计算机毕业设计木哥3 天前
计算机毕设选题推荐:基于Java+SpringBoot物品租赁管理系统【源码+文档+调试】
java·vue.js·spring boot·mysql·spark·毕业设计·课程设计
hdsoft_huge4 天前
Java & Spring Boot常见异常全解析:原因、危害、处理与防范
java·开发语言·spring boot