美文网首页
easyexcel 导入

easyexcel 导入

作者: 架构师与哈苏 | 来源:发表于2020-04-03 15:29 被阅读0次
    package com.meeno.framework.util.easyexcel.entity;
    
    import cn.afterturn.easypoi.excel.annotation.Excel;
    import lombok.AllArgsConstructor;
    import lombok.Data;
    import lombok.NoArgsConstructor;
    
    import java.util.Date;
    
    /**
     * @description:
     * @author: Wzq
     * @create: 2020-03-24 20:19
     */
    @Data
    @AllArgsConstructor
    @NoArgsConstructor
    public class AuthExcelModel {
    
        private String code;
    
        private String name;
    
        private String  categoryName;
    
        private String categoryChildrenName;
    
        private String parentCode;
    
        private String parentName;
    
        private Date createDate;
    
    
    }
    
    
    
    
    
    package com.meeno.framework.util.easyexcel.listener;
    
    //import com.alibaba.excel.context.AnalysisContext;
    //import com.alibaba.excel.event.AnalysisEventListener;
    import com.meeno.framework.util.easyexcel.entity.AuthExcelModel;
    import lombok.Data;
    
    import java.util.ArrayList;
    import java.util.List;
    
    /**
     * @description: Listener
     * @author: Wzq
     * @create: 2020-03-25 10:16
     */
    @Data
    public class AuthExcelModelListener  extends AnalysisEventListener<AuthExcelModel> {
    
        List<AuthExcelModel> list = new ArrayList<AuthExcelModel>();
    
        @Override
        public void invoke(AuthExcelModel authExcelModel, AnalysisContext analysisContext) {
            list.add(authExcelModel);
        }
    
        @Override
        public void doAfterAllAnalysed(AnalysisContext analysisContext) {
    
        }*/
    }
    
    EasyExcel.read(file.getInputStream(), AuthExcelModel.class, authExcelModelListener).sheet().doRead();
    

    相关文章

      网友评论

          本文标题:easyexcel 导入

          本文链接:https://www.haomeiwen.com/subject/ofohphtx.html