This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Other Open Source Projects and the fly likes create Excel sheet between existing sheet using poi Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Products » Other Open Source Projects
Bookmark "create Excel sheet between existing sheet using poi" Watch "create Excel sheet between existing sheet using poi" New topic
Author

create Excel sheet between existing sheet using poi

Java Pradeep Kumar Kumar
Greenhorn

Joined: Feb 22, 2013
Posts: 7
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

Joined: Jul 26, 2007
Posts: 10167
    
    8

I think this will be better suited on the Open source forum. Moving...


[How to ask questions] [Donate a pint, save a life!] [Onff-turn it on!]
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41087
    
  43
The org.apache.poi.ss.usermodel.Workbook interface has a method that -according to its javadocs- lets you do exactly that.


Ping & DNS - my free Android networking tools app
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: create Excel sheet between existing sheet using poi
 
Similar Threads
Strange error with Apache POI
Problem in opening xlsx file when downloaded using a action class
How do i format a string to date
How to add a an object to a arraylist without overwriting other objects in the arraylist
Open a new worksheet using jExcel