美文网首页
easypoi自定义字段导出到表格

easypoi自定义字段导出到表格

作者: 蛋皮皮652 | 来源:发表于2020-04-15 08:49 被阅读0次

    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

    相关文章

      网友评论

          本文标题:easypoi自定义字段导出到表格

          本文链接:https://www.haomeiwen.com/subject/ltrqvhtx.html