package common;

import com.alibaba.excel.context.AnalysisContext;
import com.alibaba.excel.event.AnalysisEventListener;
import com.alibaba.fastjson.JSON;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.ArrayList;
import java.util.List;

/**
 * @Auther: 胡锐
 * @Description:
 * @Date: 2021/3/20 20:51
 */
public class DemoDataListener extends AnalysisEventListener<ExcelModel> {

    private static final Logger LOGGER = LoggerFactory.getLogger(DemoDataListener.class);

    List<ExcelModel> list = new ArrayList<>();

    @Override
    public void invoke(ExcelModel excelModel, AnalysisContext analysisContext) {
        System.out.println(JSON.toJSONString(excelModel));
        list.add(excelModel);
    }

    @Override
    public void doAfterAllAnalysed(AnalysisContext analysisContext) {
        LOGGER.info("所有数据解析完成！");
        System.out.println("所有数据解析完成");
    }
}
