当前位置:网站首页>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 !");
}
边栏推荐
- Multimodal model sketch (1)
- vulnhub:SolidState
- Sword finger offer 41. median in data flow
- 动态规划问题(六)
- Okaleido ecological core equity Oka, all in fusion mining mode
- Oracle super full SQL, details crazy
- 1-6 state and binding events
- Review of categories 1-4
- [CNN] Why is the convolution kernel size of CNN usually odd
- Real time data warehouse: Didi's real-time data warehouse landing practice
猜你喜欢

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

【C】 Drink soda and find a single dog

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

Newscenter, advanced area of attack and defense world web masters

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

Eye of depth (18) -- partial derivative

研发效能的道法术器

【小程序项目开发 -- 京东商城】uni-app 商品分类页面(上)

Leetcode62. Different paths

Yolov5 learning notes (I) -- principle overview
随机推荐
Real time data warehouse: Netease strictly selects the practice of real-time data warehouse based on Flink
Applet waterfall flow, upload pictures, simple use of maps
curl (7) Failed connect to localhost8080; Connection refused
Advanced area of attack and defense world web masters training www robots
Data warehouse: Doris' application practice in meituan
CV target detection model sketch (2)
Samsung asset management (Hong Kong) launched yuancosmos ETF to focus on investing in the future tuyere track
Erc20 Standard Code
[TA frost wolf \u may - "hundred people plan"] Figure 3.6 texture compression - inclusion slimming
研发效能的道法术器
【C】 Replace spaces and realize binary parity bit exchange of integers by macros
Everything you have learned will come in handy at some point in your life (turn)
"Method not allowed", 405 problem analysis and solution
Plato farm is expected to further expand its ecosystem through elephant swap
Dual for loop optimization
Idea error running 'application' command line is too long solution
Summary of wrong questions of software designers
How NAT configures address translation
ES6 operation tutorial
PIP image download