easypoi自定义字段导出到表格

1.添加依赖

cn.afterturn

easypoi-base

3.2.0

cn.afterturn

easypoi-web

3.2.0

cn.afterturn

easypoi-annotation

3.2.0

2.编写类

public static void test() {

try {

List beanList =new ArrayList();

        beanList.add(new ExcelExportEntity("学生姓名", "name"));

        beanList.add(new ExcelExportEntity("学生性别", "sex"));

        beanList.add(new ExcelExportEntity("进校日期", "registrationDate"));

        beanList.add(new ExcelExportEntity("出生日期", "birthday"));

        List> list =new ArrayList>();

        for(int i=0;i<5;i++){

Map map =new HashMap<>();

            map.put("name",i+"aa");

            map.put("sex",i+"bb");

            map.put("registrationDate",i+"cc");

            map.put("birthday",i+"dd");

            list.add(map);

        }

Workbook workbook = ExcelExportUtil.exportExcel(new ExportParams("测试", "测试"), beanList,list);

        FileOutputStream fos =new FileOutputStream("D:/excel/ExcelExportForMap.tt.xls");

        workbook.write(fos);

        fos.close();

    }catch (FileNotFoundException e) {

e.printStackTrace();

    }catch (IOException e) {

e.printStackTrace();

    }

}

public static void main(String[] args) {

Test.test();

}

参考链接: https://opensource.afterturn.cn/doc/easypoi.html#302

你可能感兴趣的:(easypoi自定义字段导出到表格)