当前位置:网站首页>[file download] easyexcel quick start
[file download] easyexcel quick start
2022-07-29 05:07:00 【No bug is the biggest bug】
One 、 Introduce dependencies
<!-- Easyexcel-->
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>easyexcel</artifactId>
<version>2.1.3</version>
</dependency>
<!-- POI-->
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi</artifactId>
<version>3.17</version>
</dependency>
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi-ooxml</artifactId>
<version>3.17</version>
</dependency>
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi-ooxml-schemas</artifactId>
<version>3.17</version>
</dependency>
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi-scratchpad</artifactId>
<version>3.17</version>
</dependency>
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi-excelant</artifactId>
<version>3.17</version>
</dependency>Two 、 Entity class annotation configuration
@Data
public class User {
@ExcelProperty(" user name ")
private String username;
@ExcelProperty(" password ")
private String password;
@ExcelProperty(" Gender ")
private String age;
public User(String username, String password, String age) {
this.username = username;
this.password = password;
this.age = age;
}
}
3、 ... and 、 Business code
@GetMapping("download")
public void download(HttpServletResponse response) throws IOException {
List<User> list = new ArrayList<>();
list.add(new User(" Zhang San ","aaa"," male "));
list.add(new User(" Li Si ","bbb"," Woman "));
list.add(new User(" Wang Wu ","ccc"," male "));
response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
response.setCharacterEncoding("utf-8");
response.setHeader("Content-disposition", "attachment; filename= user .xlsx");
EasyExcel.write(response.getOutputStream(), User.class).sheet(" user ").doWrite(list);
}Four 、 Interface access ( The file storage location can be customized )

5、 ... and 、 see file

边栏推荐
- How to set row height and column width in excel? The method of setting row height and column width in Excel
- def fasterrcnn_ resnet50_ FPN () instance test
- Huawei ilearning AI mathematics foundation course notes
- tmux随笔
- 让你的正则表达式可读性提高一百倍
- How to install Office2010 installation package? How to install Office2010 installation package on computer
- Sparksql inserts or updates in batches and saves data to MySQL
- Mysql:the user specified as a definer ('root '@'%) does not exist
- MySQL定时调用预置函数完成数据更新
- Numpy basic learning
猜你喜欢

IOS interview preparation - Online

Solution to the fourth game of 2022 Hangzhou Electric Multi school league

虚拟偶像的歌声原来是这样生成的!

荣耀2023内推,内推码ambubk

五个关联分析,领略数据分析师一大重要必会处理技能

Force deduction ----- sort odd and even subscripts respectively

How does word view document modification traces? How word views document modification traces

office2010每次打开都要配置进度怎么解决?

Jackson解析JSON详细教程

What if excel is stuck and not saved? The solution of Excel not saved but stuck
随机推荐
搭建手机APP需要用到什么服务器
那个准时上下班,从不愿意加班加点的人,在我前面升职了...
On prepayment of house purchase
Let you understand several common traffic exposure schemes in kubernetes cluster
What if the office prompts that the system configuration cannot run?
PHP判断用户是否已经登录,如果登录则显示首页,如果未登录则进入登录页面或注册页面
What are the core features of the digital transformation of state-owned construction enterprises?
开源汇智创未来 | 2022开放原子全球开源峰会 openEuler 分论坛圆满召开
Wps如何使用智能填充快速填充数据?Wps快速填充数据的方法
pytorch学习笔记
AttributeError: ‘module‘ object has no attribute ‘create_connection‘
Force deduction ----- sort odd and even subscripts respectively
如何安装office2010安装包?office2010安装包安装到电脑上的方法
SGuard64.exe ACE-Guard Client EXE:造成磁盘经常读写,游戏卡顿,及解决方案
Go memory model for concurrency
【config】配置数组参数
Wechat picture identification
How to debug UDP port
How does excel filter out the content you want? Excel table filtering content tutorial
Torch.nn.crossentropyloss() details