zoukankan      html  css  js  c++  java
  • easyExcel使用

    这个使用起来感觉很简单,

    但是,如果pom.xml文件已经有poi依赖,最好删掉,
    因为poi的版本低于easyExcel里面的poi版本,线上会报错,

    easyExcel里面已经包含了poi。

    使用步骤

    1、导入依赖

    <dependency>
    <groupId>com.alibaba</groupId>
    <artifactId>easyexcel</artifactId>
    <version>2.1.4</version>
    </dependency>

    2、demo

    public Result exportDemo(DemoDto dto, HttpServletResponse response) {
    try{
    List<DemoVO> resultList = demoService.exportDemo(dto);

    List<DemoExport> exportEntitys = new ArrayList<>();
    for(int i=0;i<resultList.size();i++){
    DemoVO vo =resultList.get(i);
    DemoExport exportEntity = new ZtoRouteApplyLineExport();
    BeanUtil.copyPropertiesNew(vo, exportEntity);
    exportEntity.setIndex(i+1);
    exportEntitys.add(exportEntity);
    }
    EasyExcelUtil.writeExcel(response, exportEntitys, "测试用导出模版", "sheet1", exportDemo.class, "UTF-8");
    return Result.success();
    }catch (Exception e){
    logger.error(e.getMessage(),e);
    return Result.error(BizConstant.STATUS_CODE_ERROR, BizConstant.MESSAGE_ERROR);
    }
    }

  • 相关阅读:
    Js变量类型
    前端面试题HTML
    AP聚类
    锚点
    html
    Active Learning主动学习
    z-index
    position
    学习笔记_卷积神经网络
    学习笔记_深度学习的数学基础
  • 原文地址:https://www.cnblogs.com/cq-Lucky/p/12761037.html
Copyright © 2011-2022 走看看