EasyExcel:简单读取本地文件


        <dependency>
            <groupId>com.alibabagroupId>
            <artifactId>easyexcelartifactId>
            <version>3.1.1version>
            <exclusions>
                <exclusion>
                    <groupId>org.apache.poigroupId>
                    <artifactId>poiartifactId>
                exclusion>
                <exclusion>
                    <groupId>org.apache.poigroupId>
                    <artifactId>poi-ooxmlartifactId>
                exclusion>
                <exclusion>
                    <groupId>org.apache.poigroupId>
                    <artifactId>poi-ooxml-schemasartifactId>
                exclusion>
            exclusions>
        dependency>


        <dependency>
            <groupId>com.alibabagroupId>
            <artifactId>easyexcelartifactId>
            <version>3.1.1version>
        dependency>

我这里是因为还引入了poi的依赖冲突了,所以需要排除一些。二选一

EasyExcel:简单读取本地文件_第1张图片

@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());
    }
@Data
@AllArgsConstructor
@NoArgsConstructor
public class HistoryPoDemo {
    private String item1;
    private String item2;
    private Long item3;
    private String ifOut;
}

你可能感兴趣的:(spring,boot)