当前位置:网站首页>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 !");
}
边栏推荐
- 【微服务~Nacos】Nacos服务提供者和服务消费者
- Laravel8 middleware realizes simple permission control
- 动态规划问题(二)
- Web系统常见安全漏洞介绍及解决方案-sql注入
- Network traffic monitoring tool iftop
- Linux之yum安装MySQL
- Virtual lab basic experiment tutorial -8. Fourier transform (1)
- Everything you have learned will come in handy at some point in your life (turn)
- 动态规划问题(一)
- Where is sandbox's confidence in rejecting meta's acquisition of meta universe leader sand?
猜你喜欢

mysql索引失效的常见9种原因详解

Using recursion and chain header interpolation to realize the group turnover of linked lists -- leetcode25 K group turnover linked lists

PHP语言基础知识(超详细)

Worthington - chemical properties and related studies of Worthington trypsin

研发效能的道法术器

Advanced area of attack and defense world web masters ics-06

“Method Not Allowed“,405问题分析及解决

动态规划问题(三)

Concurrency in go

Why is it so difficult for the SEC to refuse the application for transferring gray-scale GBTC to spot ETF? What is the attraction of ETF transfer?
随机推荐
Using recursion and chain header interpolation to realize the group turnover of linked lists -- leetcode25 K group turnover linked lists
Feign call fails. JSON parse error illegal character ((ctrl-char, code 31)) only regular white space (R
Android studio连接MySQL并完成简单的登录注册功能
Okaleido ecological core equity Oka, all in fusion mining mode
ZABBIX 5.0 uses its own redis template for monitoring
Attack and defense world web master advanced area PHP_ rce
动态规划问题(七)
Servlet operation principle_ API details_ Advanced path of request response construction (servlet_2)
Leetcode59. Spiral matrix II
@Detailed explanation of the use of transactional annotation
Advanced area of attack and defense world web masters ics-06
Application of Devops in Internet of things solutions
Cmake basic learning
Eye of depth (18) -- partial derivative
Worthington - chemical properties and related studies of Worthington trypsin
PMP Exam countdown, look at 3A pass bag!
Solution: direct local.Aar file dependencies are not supported when building an aar
Intelligent trash can (VII) -- Introduction and use of sg90 steering gear (Pico implementation of raspberry pie)
跳表的原理
Idea2021.2 installation and configuration (continuous update)