easyexcel(二)读

读取excel需要先写一个监听器继承 AnalysisEventListener

    //使用无映射读取数据
    @Test
    public void noModel() throws FileNotFoundException {
        FileInputStream in=new FileInputStream("test2.xls");
        //AnalysisEventListener的匿名内部类
        AnalysisEventListener<List<String>> listener=new AnalysisEventListener<List<String>>() {
            @Override
            public void invoke(List<String> object, AnalysisContext context) {
                System.out.println(context.getCurrentRowNum()+" data:"+object);
            }

            @Override
            public void doAfterAllAnalysed(AnalysisContext context) {
                System.out.println("doAfterAllAnalysed...");
            }
        };

        ExcelReader reader= EasyExcelFactory.getReader(new BufferedInputStream(in),listener);
        reader.read();
    }

  //使用有映射模型读取数据...
原文地址:https://www.cnblogs.com/yjh1995/p/13554199.html