EasyPOI是在jeecg的poi模块基础上,继续开发独立出来的,可以说是2.0版本,EasyPoi封装的目的和jeecg一致,争取让大家write less do more ,在这个思路上easypoi可以让大家几乎不写代码的情况下完成Excel的导入导出,Excel的模板导出(制作漂亮的Excel),Word模板的导出,让大家从复杂的POI的接口中解脱出来,同时更迅速的完成工作.

EasyPoi的特性

•      注解是基础,让大家见名知意

•      注解是核心,让大家快速开发

•      简单的导出导入接口,可以快速完成

•      简单的数据接口,自定义数据

•      Excel模板,美化的Excel,程序一天,Excel1分钟

•      Word模板,通知类文件的强大神器

•      SpringView集成

easypoi在项目中的应用:

需要引入的jar包:

        <!--easypoi导出excel-->
<!--easypoi-base 导入导出的工具包,可以完成Excel导出,导入,Word的导出,Excel的导出功能-->
<dependency>
<groupId>org.jeecg</groupId>
<artifactId>easypoi-base</artifactId>
<version>2.3.1</version>
</dependency>
<!--easypoi-web 耦合了spring-mvc 基于AbstractView,极大的简化spring-mvc下的导出功能-->
<dependency>
<groupId>org.jeecg</groupId>
<artifactId>easypoi-web</artifactId>
<version>2.3.1</version>
</dependency>
<!--easypoi-annotation 基础注解包,作用与实体对象上,拆分后方便maven多工程的依赖管理-->
<dependency>
<groupId>org.jeecg</groupId>
<artifactId>easypoi-annotation</artifactId>
<version>2.3.1</version>
</dependency>

然后在实体类中添加easypoi的注解:

@ExcelTarget("summaryexcel")
@Data
public class SummaryExcel { @Excel(name = "日期", orderNum = "1", mergeVertical = true, isImportField = "date")
private String date;//当天日期 @Excel(name = "能源类型", orderNum = "2", mergeVertical = true, isImportField = "type")
private String type; // 能源类型 @Excel(name = "能源用量", orderNum = "3", mergeVertical = true, isImportField = "sum")
private Double sum; // 用量
}

然后就可以在controller层直接使用easypoi:

  @GetMapping("getexcel")
  public void download(HttpServletRequest request, HttpServletResponse response,String start,String end) throws Exception {
// 告诉浏览器用什么软件可以打开此文件
response.setHeader("content-Type", "application/vnd.ms-excel");
// 下载文件的默认名称
response.setHeader("Content-Disposition", "attachment;filename=" + URLEncoder.encode("数据表","UTF-8") + ".xls");
//编码
response.setCharacterEncoding("UTF-8");
List<SummaryExcel> list = summaryService.summaryexcel(start,end);
Workbook workbook = ExcelExportUtil.exportExcel(new ExportParams(), SummaryExcel.class, list);
workbook.write(response.getOutputStream());
}

这样一个简单的用easypoi实现excel导出就完成了。

easypoi在开源中国:https://www.oschina.net/news/54995/jeecg-easypoi-2-0-3

easypoi文档:http://easypoi.mydoc.io/

使用easypoi导出excel的更多相关文章

  1. SpringBoot使用Easypoi导出excel示例

    SpringBoot使用Easypoi导出excel示例 https://blog.csdn.net/justry_deng/article/details/84842111

  2. EasyPoi导出Excel

    这几天一直在忙工作中的事情,在工作中有一个问题,可能是因为刚开始接触这个EasyPoi,对其也没有太多的理解,在项目中就使用了,有一个需求,是要导出项目中所有的表格,今天就对这个需求进行分析和实现吧; ...

  3. 关于EasyPoi导出Excel

    如果你觉得Easypoi不好用,喜欢用传统的poi,可以参考我的这篇博客:Springmvc导出Excel(maven) 当然了,万变不离其宗.Easypoi的底层原理还是poi.正如MyBatis ...

  4. easyPOI导出excel报错

    http-nio--exec- at :: - excel cell export error ,data is :com.jn.ssr.superrescue.web.qc.dto.Automati ...

  5. EasyPoi 导出Excel(ExcelExportEntity生成表头)

    [引入依赖] <!--easypoi--> <dependency> <groupId>cn.afterturn</groupId> <artif ...

  6. 使用EasyPOI导出excel示例

    package com.mtoliv.sps.controller; import java.io.IOException; import java.io.OutputStream; import j ...

  7. Vue+EasyPOI导出Excel(带图片)

    一.前言 平时的工作中,Excel 导入导出功能是非常常见的功能,无论是前端 Vue (js-xlsx) 还是 后端 Java (POI),如果让大家手动编码实现的话,恐怕就很麻烦了,尤其是一些定制化 ...

  8. java导出excel(easypoi)

    介绍 easypoi功能如同名字easy,主打的功能就是容易,让一个没见接触过poi的人员 就可以方便的写出Excel导出,Excel模板导出,Excel导入,Word模板导出,通过简单的注解和模板 ...

  9. easypoi导出单个sheet和多个sheet

    今天有时间研究了一下easypoi,感觉使用了easypoi导出excel方便了很多,不用写很多复杂的反射,只需要使用注解和一些工具类就可以实现常用的excel的导出,接下来介绍一下easypoi如何 ...

随机推荐

  1. python 压缩每周生成的数据文件

    为了便于整理部分业务数据,以及存储管理, 写了此脚本.后期如果有需求,再改一下. #!/usr/bin/env python #coding:utf8 import os,sys,time,comma ...

  2. debian下配置双核cpu

    ----------------------------文:jiqing(吉庆) http://hi.baidu.com/jiqing0925email: jiqingwu@gmail.comdate ...

  3. element-UI 表单图片判空验证问题

    本文地址:http://www.cnblogs.com/veinyin/p/8567167.html  element-UI的表单验证似乎并没有覆盖到文件上传上面,当我们需要在表单里验证图片时,就会出 ...

  4. Nginx服务优化详解

    Nginx服务优化详解 1.隐藏Nginx版本信息 编辑主配置文件nginx.conf,在http标签中添加代码 server_tokens off;来隐藏软件版本号. 2.更改Nginx服务启动的默 ...

  5. python作业堡垒机(第十三周)

    作业需求: 1. 所有的用户操作日志要保留在数据库中 2. 每个用户登录堡垒机后,只需要选择具体要访问的设置,就连接上了,不需要再输入目标机器的访问密码 3. 允许用户对不同的目标设备有不同的访问权限 ...

  6. Computer Vision Resources

    Computer Vision Resources Softwares Topic Resources References Feature Extraction SIFT [1] [Demo pro ...

  7. APScheduler API -- apscheduler.triggers.cron

    apscheduler.triggers.cron API Trigger alias for add_job(): cron class apscheduler.triggers.cron.Cron ...

  8. MeasureSpec介绍及使用详解

    一个MeasureSpec封装了父布局传递给子布局的布局要求,每个MeasureSpec代表了一组宽度和高度的要求.一个MeasureSpec有大小和模式组成.他有三种模式: UNSPECIFIED ...

  9. Shell-修改MySQL默认root密码

    Code: mysqltmppwd=`cat /tmp/.mysql_secret | cut -b 87-102` mysqladmin -u root -p${mysqltmppwd} passw ...

  10. Shell-判断条件总结

    -b file 若文件存在且是一个块特殊文件,则为真 -c file 若文件存在且是一个字符特殊文件,则为真 -d file 若文件存在且是一个目录,则为真 -e file 若文件存在,则为真 -f ...