This week's book giveaways are in the Refactoring and Agile forums.
We're giving away four copies each of Re-engineering Legacy Software and Docker in Action and have the authors on-line!
See this thread and this one for details.
Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

create Excel sheet between existing sheet using poi

 
Java Pradeep Kumar Kumar
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I build the code to meet my client requirement using org.apache.poi.ss.usermodel.Sheet class

Now I got a new requirement to create a new excel sheet in between two existing sheets. In the existing excel file there are already three sheets at the index numbers p,1,2. I want to create a sheet at index number 2 moving the sheet at index number 2 to 3.

I could able to find the sheets names in Excel file using the code:


for (int i = 0; i < wb.getNumberOfSheets(); i++)
{
System.out.println("Sheet name: " + wb.getSheetName(i));
}


Also, I could able to find the sheet index numbres in Excel file using the code:
System.out.println("Sheet name: " + wb.getSheetIndex("Retail - All"));

The code I used to create a new sheet is: Sheet failuresSheet= wb.createSheet("Failures"); This is creating a new sheet at end. Please let me know the correct code for my requirement.

Remember that I used the class org.apache.poi.ss.usermodel.Sheet to meet my requirement.

Please let me know to create a sheet at Index no 2 moving the sheet at index no 2 to 3. Thanks you in advance.
 
Maneesh Godbole
Saloon Keeper
Posts: 11021
12
Android Eclipse IDE Google Web Toolkit Java Mac Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think this will be better suited on the Open source forum. Moving...
 
Ulf Dittmer
Rancher
Pie
Posts: 42967
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The org.apache.poi.ss.usermodel.Workbook interface has a method that -according to its javadocs- lets you do exactly that.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic