Search...
FAQs
Subscribe
Pie
FAQs
Recent topics
Flagged topics
Hot topics
Best topics
Search...
Search Coderanch
Advance search
Google search
Register / Login
This week's giveaway is in the
Spring
forum.
We're giving away four copies of
Microservices Testing (Live Project)
and have Chris Love & Andres Sacco on-line!
See
this thread
for details.
Win a copy of
Microservices Testing (Live Project)
this week in the
Spring
forum!
Mak Cash
Greenhorn
+ Follow
1
Posts
0
Threads
0
Cows
since Jun 07, 2021
Merit Badge info
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
Ranch Hand Scavenger Hunt
Number Posts (1/100)
Number Threads Started (0/100)
Number Cows Received (0/5)
Number Likes Received (0/10)
Number Likes Granted (0/20)
Set bumper stickers in profile (0/3)
Report a post to the moderators (0/1)
Edit a wiki page (0/1)
Create a post with an image (0/2)
Greenhorn Scavenger Hunt
First Post
Number Posts (1/10)
Number Threads Started (0/10)
Number Likes Received (0/3)
Number Likes Granted (0/3)
Set bumper stickers in profile (0/1)
Set signature in profile
Search for a post/thread (0/3)
Set a watch on a thread
Save thread as a bookmark
Create a post with an image (0/1)
Recent posts by Mak Cash
Copying a sheet from an excel file to another excel file using Apache POI
Hello All -
I am not sure if this was still a problem ....
But this is what I am doing now ... to copy a sheet. ...
1> clone old sheet to new
2> rename new sheet to new name ..
private XSSFSheet copyWorksheet(XSSFWorkbook wb, String oldSheetName, String newSheetName, boolean safeCreateFlag) throws Exception { XSSFSheet oldSheet = wb.getSheet(oldSheetName); if (oldSheet == null) { throw new Exception("Sheet with name " + oldSheetName + " doesnt exist"); } XSSFSheet newSheet = wb.getSheet(newSheetName); int newSheetIndex = -1; if (newSheet != null) { if (safeCreateFlag) { newSheetIndex = wb.getSheetIndex(newSheetName); wb.removeSheetAt(newSheetIndex); } else { throw new Exception("Sheet with name " + newSheetName + " already exists"); } } int oldSheetNo = wb.getSheetIndex(oldSheet); newSheet = wb.cloneSheet(oldSheetNo); int newSheetNo = wb.getSheetIndex(newSheet); wb.setSheetName(newSheetNo, newSheetName); if (newSheetIndex >= 0) { wb.setSheetOrder(newSheetName, newSheetIndex); } return newSheet; }
show more
1 year ago
Other Open Source Projects