当前位置:网站首页>Use hutool tool class to operate excel with more empty Sheet1
Use hutool tool class to operate excel with more empty Sheet1
2022-07-29 00:19:00 【Nanchang pengyuyan】
To do a project in the near future, you need to be right excel Read and write , be used hutool Tool class , There are many edited tables sheet The situation of
hutool After operation excel Always bring a default empty sheet1, Study it and share it with you 
Official documents say that this solution :
// Define the table name when initializing
ExcelWriter writer = new ExcelWriter("d:/aaa.xls", " surface 1");
// Switch sheet, At this point, from 0 OK, start writing
writer.setSheet(" surface 2");
...
writer.setSheet(" surface 3");
...
It doesn't feel quite in line with my actual situation
try (ExcelWriter writer = new ExcelWriter(drawConfig.getExcelPath())) {
writer.setSheet(1).renameSheet(" The operation log ")
.setColumnWidth(1, 28)
.setColumnWidth(3, 28)
.write(drawRows, false)
.close();
}catch (IllegalArgumentException e){
...
}
After thinking about it, I should use ExcelWriter By default, a sheet1, Here, read first and then write , The problem is solved
ExcelReader reader;
try {
reader = ExcelUtil.getReader(drawConfig.getExcelPath());
ExcelWriter writer = reader.getWriter();
writer.setSheet(1).renameSheet(" The operation log ")
.setColumnWidth(1, 28)
.setColumnWidth(3, 28)
.write(drawRows, false)
.close();
} catch (POIException e) {
throw new UniException(" file does not exist !");
}
边栏推荐
- Sword finger offer 41. median in data flow
- Using recursion and chain header interpolation to realize the group turnover of linked lists -- leetcode25 K group turnover linked lists
- Plato farm is expected to further expand its ecosystem through elephant swap
- Eye of depth (18) -- partial derivative
- CMake 基础学习
- Principle of meter skipping
- 2022网络安全学习路线 非常详细 推荐学习
- @Detailed explanation of the use of transactional annotation
- 研发效能的道法术器
- 12个MySQL慢查询的原因分析
猜你喜欢

Worthington - chemical properties and related studies of Worthington trypsin

Eye of depth (18) -- partial derivative

Centos7 install mysql8

html+css+php+mysql实现注册+登录+修改密码(附完整代码)

Web系统常见安全漏洞介绍及解决方案-sql注入

Real time data warehouse: meituan's implementation of real-time data warehouse construction based on Flink

Idea error running 'application' command line is too long solution

curl (7) Failed connect to localhost8080; Connection refused

ZABBIX 5.0 uses its own redis template for monitoring

Newscenter, advanced area of attack and defense world web masters
随机推荐
Real time data warehouse: Didi's real-time data warehouse landing practice
Compilation principle research study topic 2 -- recursive descent syntax analysis design principle and Implementation
How can Plato obtain premium income through elephant swap in a bear market?
Android studio connects to MySQL and completes simple login and registration functions
Leetcode 763. partition labels divide alphabetic intervals (medium)
MySQL事务(transaction) (有这篇就足够了..)
递归/回溯刷题(中)
Data warehouse: Doris' application practice in meituan
Idea2021.2 installation and configuration (continuous update)
Oracle create tablespaces and users
Opencv macro definition
@Transactional 注解使用详解
【C】 Reverse string (two recursive ideas)
2022网络安全学习路线 非常详细 推荐学习
JS advanced ES6 ~ es13 new features
pnpm的安装与使用
Web系统常见安全漏洞介绍及解决方案-sql注入
Laravel8 middleware realizes simple permission control
Develop effective Tao spell
Leetcode64. Minimum path sum