第一步:编写excel模板

第二步:引入pom文件 版本是个大坑

        <poi.version>4.0.0</poi.version><easypoi.version>4.1.0</easypoi.version>
<!-- excel工具 --><dependency><groupId>org.apache.poi</groupId><artifactId>poi-ooxml</artifactId><version>${poi.version}</version></dependency><!-- excel --><dependency><groupId>cn.afterturn</groupId><artifactId>easypoi-base</artifactId><version>${easypoi.version}</version></dependency><dependency><groupId>cn.afterturn</groupId><artifactId>easypoi-web</artifactId><version>${easypoi.version}</version></dependency><dependency><groupId>cn.afterturn</groupId><artifactId>easypoi-annotation</artifactId><version>${easypoi.version}</version></dependency>

第三步:代码编写

/** 导出学员注册列表 */@PostMapping("/StatisticsExport")@ResponseBodypublic String queryExamExport(StudyClass studyClass) throws FileNotFoundException {List<StudyStuRegistStatistics> list =iStudyStuRegistService.selectStatisticsNum(studyClass.getDeptId(),studyClass.getPersonType(),studyClass.getTrainStartDate(),studyClass.getTrainStartDate1());if (list.size() == 0) {throw new BusinessException("未查询到信息!");}Map<String, Object> map = new HashMap<String, Object>();map.put("deptName", String.valueOf(ShiroUtils.getSysUser().getDeptId()));map.put("date",String.valueOf(new Date()));List<Map<String,String>> mapList = new ArrayList<Map<String, String>>();for (int i=0;i<list.size();i++){Map<String, String> lm = new HashMap<String, String>();lm.put("personType",list.get(i).getPersonType());lm.put("planNum",list.get(i).getPlanNum());lm.put("certNum",list.get(i).getCertNum());lm.put("beginningNum",list.get(i).getBeginningNum());lm.put("refreshmentNum",list.get(i).getRefreshmentNum());lm.put("changCertNum",list.get(i).getChangCertNum());lm.put("kosekiNum",list.get(i).getKosekiNum());lm.put("TestPassRate",list.get(i).getTestPassRate());mapList.add(lm);}map.put("maplist",mapList);TemplateExportParams params = new TemplateExportParams(profile+"/业绩查询.xls");//导出数据Workbook workbook = ExcelExportUtil.exportExcel(params, map);File savefile = new File(profile+"/业绩查询.xls");if (!savefile.exists()) {savefile.mkdirs();}String uuid = UUIDGenerator.getUUID();FileOutputStream fos = null;try {fos = new FileOutputStream(profile + "/download/业绩查询" + uuid + ".xls");workbook.write(fos);fos.close();} catch (IOException e) {e.printStackTrace();}return "业绩查询" + uuid + ".xls";}

第四步:前端

<div class="btn-group-sm" id="toolbar" role="group"><a class="btn btn-warning" onclick="dow()"><i class="fa fa-download"></i> 导出</a></div>function dow() {$.ajax({cache : true,type : "POST",url : ctx + "system/studyStuRegistStatistics/StatisticsExport",async : false,error : function(request) {$.modal.alertError("系统错误");},success : function(data) {console.log(data);// window.location.href = ctx + "common/temdownload?fileName=" + encodeURI(data.) + "&delete=" + false;}});}

easypoi导出模板excel相关推荐

  1. 使用easypoi 导出模板 图片填充

    使用easypoi 导出模板 图片填充 官网地址:EasyPOI 以下就是模板常用的指令: 三目运算 {{test ? obj:obj2}} n: 表示 这个cell是数值类型 {{n:}} le: ...

  2. springmvc使用easypoi导出导入Excel表(1):导出Excel表

    编译工具:eclipse 项目:maven+ssm springmvc使用easypoi导出导入Excel表(2):导入Excel表 在pom.xml引入easypoi的依赖包: <!--eas ...

  3. EasyPoi导出复杂Excel

    简介 还是关于毕设的,现在有个导出复杂Excel的需求,与前面的文章关系很大,感兴趣的看一下哈

  4. 基于SpringMVC+EasyPoi,采用Excel模板方式实现Excel在线预览和导出(2021版)

    一.背景:某工厂需要查看指定年度的设备维护计划,一般需要把全年72个周,每个周做哪些维护工作排班排出以及工时统计出来,在正式生成维护工单之前,需要先确认下.维护计划大概是某一周要执行哪些维护项,大概长 ...

  5. 使用EasyPOI导出Excel模板数据(含图片)

    使用EasyPOI导出Excel模板数据(含图片) EasyPOI功能如同名字Easy,主打的功能就是容易,让一个没接触过POI的人员可以方便的写出Excel导出,Excel模板导出,Excel导入, ...

  6. Easypoi使用模板导出文档或excel表格详解

    Easypoi使用模板导出docx文档或excel表格详解 **doc或docx文档的模板导出** **Excel的模板导出** 话不多说先上依赖 <dependency><grou ...

  7. EasyPOI 根据模板导出excel时,无法自适应行高得解决方案记录

    目录 EasyPOI 根据模板导出excel时,无法自适应行高得解决方案记录 首先说一下问题得场景 第一步 第二步 第三步 第四步 第五步 第六步 第七步 (就是这个方法!) EasyPOI 根据模板 ...

  8. easypoi 模板导入、导出合并excel单元格功能

    easypoi 模板导入.导出合并单元格功能 参考: hutool 导出复杂excel(动态合并行和列) java使用poi读取跨行跨列excel springboot集成easypoi并使用其模板导 ...

  9. easypoi导出数值型_SpringBoot使用EasyPoi进行数据导入导出Excel(一)

    在实际项目开发中,对于Excel的导入导出还是很常见的需求,比如说将数据根据模板批量导入到数据库中,以及将数据库中的数据批量导出陈Excel的形式 现有需求: 下载固定的导入Excel模板 导入Exc ...

最新文章

  1. 缓存伪静态html,伪静态缓存(整站静态化)
  2. 【SICP练习】9 练习1.15
  3. LVS集群---做前端调度器搭建使用
  4. node debug包
  5. leetcode 752. Open the Lock | 752. 打开转盘锁(BFS)
  6. 那一天,那一月,那一年,那一世,那一瞬
  7. 轻量级ORM框架Dapper应用二:使用Dapper实现CURD操作
  8. 为什么要学linux命令以及linux(ubuntu)的文件与目录命令
  9. 数学分析:函数的可积条件
  10. 工业视觉检测厂家十大排名
  11. 用户绑定手机号的思考
  12. ImportError: DLL load failed while importing QtWidgets: 找不到指定的程序
  13. mac 虚拟打印机:
  14. 2021牛客多校6 I Intervals on the Ring
  15. GO语言基础----简易计算器
  16. 人脸旋转对齐(opencv-python)
  17. 动手学区块链学习笔记(二):区块链以及工作量证明算法
  18. 7-1 计算π的值 (10分)_PTA_Java基础练习
  19. 【岩熹攻略】议息大会后,国庆主题迎布局良机!
  20. Kali Linux渗透

热门文章

  1. 子进程及时知道父进程已经退出的最简单方案
  2. Python爬虫实战之爬淘宝商品并做数据分析
  3. 怎么批量提取多个 Excel 文档中的图片
  4. rk3588 与 rk3399 差异比较
  5. uint与int的区别
  6. 软考高级已过,可以继续考软考中级吗?
  7. 四旋翼飞行器控制pid学习笔记
  8. 华为手机使用应用沙盒一键修改电池信息
  9. CRNN文本识别模型
  10. Wireshark软件使用