公众号:架构师与哈苏
关注公众号进入it交流群! 公众号:架构师与哈苏 不定时都会推送一些实用的干货。。。
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();
posted on 2020-09-17 13:04  公众号/架构师与哈苏  阅读(270)  评论(0编辑  收藏  举报