That's the way I already tried it. But there is something I am doing wrong 
because it still doesn't work.

Let's assume I have an Excel-Workbook with three empty sheets called "aaa", 
"bbb" and "ccc".
Now that is the code I use:

HSSFWorkbook w = new HSSFWorkbook(new FileInputStream("test.xls"));
w.setSheetOrder("ccc", 0);
w.setSheetOrder("bbb", 1);
w.setSheetOrder("aaa", 2);

FileOutputStream fileOut = new FileOutputStream("test2.xls");
w.write(fileOut);
fileOut.close();

At the end there is a new Excel-Workbook named test2.xls with three sheets, but 
still the order is "aaa", "bbb", "ccc". Why?

Matthias

-----Ursprüngliche Nachricht-----
Von: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] 
Gesendet: Dienstag, 28. August 2007 15:50
An: POI Users List
Cc: Sondermann, Matthias
Betreff: Re: Change sheet order in a workbook

It sounds like setSheetOrder is exactly what you need.  Let's say you have 
sheets named the following currently in the following order:

Sheet1
Sheet2
Sheet3

You want them to be in the following order:

Sheet2
Sheet3
Sheet1

You would make the following calls:

workbook.setSheetOrder("Sheet2",0);
workbook.setSheetOrder("Sheet3",1);
workbook.setSheetOrder("Sheet1",2);

---- [EMAIL PROTECTED] wrote: 
> Hi,
> 
> how can I order the sheets in a workbook? I found the method setSheetOrder 
> and it changes something inside the workbook but the update is not visible.
> 
> Greetings from Germany
> Matthias


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to