阿里巴巴Excel导出优化速度 ,64M内存20秒读取75M(46W行25列)的Excel(3.0.2+版本)
官方文档:EasyExcel · 语雀EasyExcel是一个基于Java的简单、省内存的读...https://www.yuque.com/easyexcel/doc/easyexcel
导入阿里Excel最新依赖
复制代码
1
2
3
4
5
6<dependency> <groupId>com.alibaba</groupId> <artifactId>easyexcel</artifactId> <version>3.0.5</version> </dependency>
创建表格实体类
复制代码
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66public class NoDataUser { @ExcelProperty("序号") //设置列名称 private Integer no; @ExcelIgnore //导入时 忽略该属性 private Long consId; @ExcelProperty("用户户号") private String consNo; @ExcelIgnore private String orgNo; @ExcelProperty("用户名称") private String consName; @ExcelProperty("供电单位") private String orgName; @ExcelProperty("运行容量(kVA)") private Double runCap; @ExcelProperty("电源类型") private String type; public Integer getNo() { return no; } public void setNo(Integer no) { this.no = no; } public Long getConsId() { return consId; } public void setConsId(Long consId) { this.consId = consId; } public String getConsNo() { return consNo; } public void setConsNo(String consNo) { this.consNo = consNo; } public String getOrgNo() { return orgNo; } public void setOrgNo(String orgNo) { this.orgNo = orgNo; } public String getConsName() { return consName; } public void setConsName(String consName) { this.consName = consName; } public String getOrgName() { return orgName; } public void setOrgName(String orgName) { this.orgName = orgName; } public Double getRunCap() { return runCap; } public void setRunCap(Double runCap) { this.runCap = runCap; } public String getType() { return type; } public void setType(String type) { this.type = type; } }
导出表格
复制代码
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16//要导出的List数据 List<NoDataUser> noDataUserList = loadCharactService.findNoDataUser(orgNo, type); String fileName = "用户信息"; try (ServletOutputStream out = response.getOutputStream()) { String disposition = "attachment; fileName=" + new String(fileName.getBytes("UTF-8"), "ISO-8859-1") + ".xls"; response.setCharacterEncoding("utf8"); response.setContentType("text/xls"); response.setHeader("Content-Disposition", "attachment; filename=" + URLEncoder.encode(fileName + ".xls", "UTF-8")); response.setHeader("Content-Disposition", disposition); EasyExcel.write(out, NoDataUser.class).sheet(1).doWrite(noDataUserList); out.flush(); } catch (IOException e) { throw new RuntimeException(); }
最后
以上就是苗条秀发最近收集整理的关于阿里开源百万级数据导出Excel表格 三步简单导出 附官方文档的全部内容,更多相关阿里开源百万级数据导出Excel表格内容请搜索靠谱客的其他文章。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复