当前位置:网站首页>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 !");
}
边栏推荐
- Idea2021.2 installation and configuration (continuous update)
- Es6操作教程
- 2022网络安全学习路线 非常详细 推荐学习
- Feign call fails. JSON parse error illegal character ((ctrl-char, code 31)) only regular white space (R
- Event extraction and documentation (2008-2017)
- Visual full link log tracking
- Advanced area of attack and defense world web masters ics-06
- IDEA报错Error running ‘Application‘ Command line is too long解决方案
- Android studio connects to MySQL and completes simple login and registration functions
- Network traffic monitoring tool iftop
猜你喜欢

Yolov5 learning notes (I) -- principle overview

Interpretation of ISO 13400 (doip) standard

Advanced area of attack and defense world web masters training www robots

Real time data warehouse: Netease strictly selects the practice of real-time data warehouse based on Flink

Application of Devops in Internet of things solutions

Visual full link log tracking

Introduction and solution of common security vulnerabilities in web system CSRF attack

Immutable x officially opens IMX token pledge detailed IMX pledge introduction optimistic about the development prospect of IMX

CV target detection model sketch (2)

110道 MySQL面试题及答案 (持续更新)
随机推荐
Android studio connects to MySQL and completes simple login and registration functions
2022 network security learning route is very detailed, recommended Learning
Compilation principle research study topic 2 -- recursive descent syntax analysis design principle and Implementation
Leetcode64. Minimum path sum
What does WGet mean
Develop effective Tao spell
Linux下安装Mysql5.7,超详细完整教程,以及云mysql连接
[applet project development -- JD mall] uni app commodity classification page (first)
【C】 Drink soda and find a single dog
@Transactional 注解使用详解
Laravel permission control
熊市下PLATO如何通过Elephant Swap,获得溢价收益?
Intelligent trash can (VII) -- Introduction and use of sg90 steering gear (Pico implementation of raspberry pie)
@Detailed explanation of the use of transactional annotation
DCAT in laravel_ Admin preliminary use record
Review of categories 1-4
Detailed explanation of 9 common reasons for MySQL index failure
Classification and determination method of Worthington stemxyme
【MySQL系列】MySQL数据库基础
SQL implementation merges multiple rows of records into one row