easypoi自定义字段导出到表格

1.添加依赖

<dependency>

<groupId>cn.afterturn</groupId>

<artifactId>easypoi-base</artifactId>

<version>3.2.0</version>

</dependency>

<dependency>

<groupId>cn.afterturn</groupId>

<artifactId>easypoi-web</artifactId>

<version>3.2.0</version>

</dependency>

<dependency>

<groupId>cn.afterturn</groupId>

<artifactId>easypoi-annotation</artifactId>

<version>3.2.0</version>

</dependency>

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

如果觉得对你有帮助,可以搜索公众号  ‘蛋皮皮’   关注作者支持一下,每天会不定时回复留言(有任何问题都可以留言哦)。

                                   

  • 1
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值