springboot easyexcel
pom..xml
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>easyexcel</artifactId>
<version>1.1.2-beat1</version>
</dependency>
AddCasesBindExl.java
package com.zjjw.cases.mode.exl; import com.alibaba.excel.annotation.ExcelProperty;
import com.alibaba.excel.metadata.BaseRowModel;
import lombok.Data; /**
* @author tongzuqi
* @date: 2019/12/10 9:26 AM
*/
@Data
public class AddCasesBindExl extends BaseRowModel { /**
* 案件类型
*/
private String casesTypeName;
/**
* 律师
*/
@ExcelProperty(value ="律师",index = 0)
private String lawyerName;
/**
* 律师电话
*/
@ExcelProperty(value ="律师电话",index = 1)
private String lawyerMobile;
/**
* 所属律所
*/
@ExcelProperty(value ="所属律所",index = 2)
private String lawyerOffice;
/**
* 单位编号
*/
private String deptCode;
/**
* 单位名称
*/
@ExcelProperty(value ="单位名称",index = 3)
private String deptName;
/**
* 审核状态
*/
private int auditStatus;
/**
* 审核状态名称
*/
@ExcelProperty(value ="审核状态名称",index = 4)
private String auditStatusStr;
/**
* 案件编号
*/
private String casesCode;
/**
* 案件名称
*/
@ExcelProperty(value ="案件名称",index = 5)
private String casesName;
/**
* 创建时间
*/
@ExcelProperty(value ="创建时间",index = 6)
private String createTime; }
ExportController.java
/**
* 新增案件列表统计
* @return
*/
@GetMapping("/addCasesBind")
public void addCasesBindPage(HttpServletResponse response , StatisticsCasesBindFo statisticsRegisterFo) throws Exception {
ExcelWriter writer = null;
OutputStream outputStream = response.getOutputStream();
long startTime=System.currentTimeMillis();
try {
//添加响应头信息
response.setHeader("Content-disposition", "attachment; filename=" + "新增案件列表.xlsx");
response.setContentType("application/msexcel;charset=UTF-8");//设置类型
response.setHeader("Pragma", "No-cache");//设置头
response.setHeader("Cache-Control", "no-cache");//设置头
response.setDateHeader("Expires", 0);//设置日期头 //实例化 ExcelWriter
writer = new ExcelWriter(outputStream, ExcelTypeEnum.XLSX, true); //实例化表单
Sheet sheet = new Sheet(1, 0, AddCasesBindExl.class);
sheet.setSheetName("sheel");
//获取数据
List<AddCasesBindExl> list = exportService.addCasesBindExport(statisticsRegisterFo);
log.info("查询时间:{}s.条数:{}",(float)(System.currentTimeMillis()-startTime)/1000,list.size()); startTime=System.currentTimeMillis();
//输出
writer.write(list, sheet);
writer.finish();
outputStream.flush();
} catch (IOException e) {
log.info("导出异常",e);
} finally {
try {
response.getOutputStream().close();
} catch (IOException e) {
log.info("导出异常",e);
}
}
log.info("导出:{}s",(float)(System.currentTimeMillis()-startTime)/1000);
}
springboot easyexcel的更多相关文章
- 使用VUE+SpringBoot+EasyExcel 整合导入导出数据
使用VUE+SpringBoot+EasyExcel 整合导入导出数据 创建一个普通的maven项目即可 项目目录结构 1 前端 存放在resources/static 下 index.html &l ...
- SpringBoot基于EasyExcel解析Excel实现文件导出导入、读取写入
1. 简介 Java解析.生成Excel比较有名的框架有Apache poi.jxl.但他们都存在一个严重的问题就是非常的耗内存,poi有一套SAX模式的API可以一定程度的解决一些内存溢出的问题 ...
- SpringBoot整合easyexcel实现Excel的导入与导出
导出 在一般不管大的或者小的系统中,各家的产品都一样,闲的无聊的时候都喜欢让我们这些程序员导出一些数据出来供他观赏,非说这是必须需求,非做不可,那么我们就只能苦逼的哼哧哼哧的写bug喽. 之前使用PO ...
- springboot整合easyexcel实现Excel导入导出
easyexcel:快速.简单避免OOM的java处理Excel工具 Java解析.生成Excel比较有名的框架有Apache poi.jxl.但他们都存在一个严重的问题就是非常的耗内存,poi有一套 ...
- SpringBoot基于easyexcel导出和写入Excel
easyexcel是阿里巴巴旗下开源项目,主要用于Excel文件的导入和导出处理,今天我们利用SpringBoot和easyexcel实战演示如何导出和写入Excel文件. 一.加入我们需要的ea ...
- SpringBoot图文教程14—SpringBoot集成EasyExcel「上」
有天上飞的概念,就要有落地的实现 概念十遍不如代码一遍,朋友,希望你把文中所有的代码案例都敲一遍 先赞后看,养成习惯 SpringBoot 图文教程系列文章目录 SpringBoot图文教程1「概念+ ...
- 使用Layui、Axios、Springboot(Java) 实现EasyExcel的导入导出(浏览器下载)
实现EasyExcel的导入导出(浏览器下载) 实现三个按钮的功能,但是却花费了一天的时间包括总结. 使用到的技术:springboot layui axios EasyExcel mybatis-p ...
- SpringBoot整合Easyexcel操作Excel,闲暇之余,让我们学习更多
关于封面:晚饭后回自习室的路上 Easyexcel 官方文档 Easyexcel | github 前言 最近也是在写的一个小练习中,需要用到这个.趁着这次就将写个整合的Demo给大家. 希望能够让大 ...
- Springboot使用EasyExcel(仅限自己收藏)
pom文件依赖 <dependency> <groupId>com.alibaba</groupId> <artifactId>easyexcel< ...
随机推荐
- ubuntu 18.04 gcc g++降级4.8版
$ sudo apt-get install -y gcc-4.8 $ sudo apt-get install -y g++-4.8 $ cd /usr/bin $ sudo rm gcc $ su ...
- Nor Flash芯片特性分析
Nor Flash是Intel在1988年推出的非易失闪存芯片,可随机读取,擦写时间长,可以擦写1~100W次,支持XIP(eXecute In Place). 本文以JS28F512M29EWH为例 ...
- Collector解读以及自定义
一.Collector接口解读: Collector接口解读: public interface Collector<T, A, R> { Supplier<A> suppli ...
- oracle rman catalog--ORA-01580: error creating control backup file
在测试rman catalog时,错误的设置了snapshot路径,报错 RMAN> show snapshot controlfile name; RMAN configuration par ...
- Java程序员面试题集(151-180)
Java面试题集(151-180) 摘要:这部分包含了Spring.Spring MVC以及Spring和其他框架整合以及测试相关的内容,除此之外还包含了大型网站技术架构相关面试内容. 151. Sp ...
- 03.大型数据库应用技术课堂测试3(java.lang.NoSuchMethodError: com.google.common.base.Preconditions.checkArgument(ZLjava/lang/String;Ljava/lang/Object;)V)
本次问题主要出在了之前没有安装hive,结构导致大部分时间花在了安装上面,主要一直报错,网上找不到相关教程.
- 4.站点克隆wget----隐写术图片----backbox linux
站点克隆wget sudo bash cd Desktop/Cloned wget -h clear wget -mk https://help.ubuntu.com/ 隐写术图片 想想朋友圈的图片 ...
- 网络通讯数据.传输json(java<==>C#)
ZC:主要是测试解决 时间转成JSON不一样的问题 ZC:java中转换时间格式的关键是“JSONUtils.getMorpherRegistry().registerMorpher(new Date ...
- 使用logstash收集java、nginx、系统等常见日志
目录 1.使用codec的multiline插件收集java日志... 1 2.收集nginx日志... 2 3.收集系统syslog日志... 3 4.使用fliter的grok模块收集mysql日 ...
- 使用extract-text-webpack-plugin插件后报错
如果你使用的webpack是4+版本,那么尝试运行npm install extract-text-webpack-plugin@next ,即可解决问题 然而最好的解决办法是在webpack4+的版 ...