Hi
Either there is a bug in setSheetOrder or I have done something wrong.
I have test it with POI 2.0RC2 and 2.5.1, but there is the same
behavior.
I have an excel-file (workbook.xls) containing three sheets:
Sheet-Pos Name Content of cell(0,0)
----------------------------------------------
0 AdFS2 "AdFS2"
1 Tabelle2 "Tabelle2"
2 Tabelle3 "Tabelle3"
----------------------------------------------
and the following code:
-----------------------
try {
POIFSFileSystem fs = new POIFSFileSystem(new
FileInputStream("workbook.xls"));
HSSFWorkbook wb = new HSSFWorkbook(fs);
HSSFSheet sheet = wb.getSheet(sSheetName);
if(sheet != null) {
wb.removeSheetAt(wb.getSheetIndex(sSheetName));
}
sheet = wb.createSheet(sSheetName);
wb.setSheetOrder(sSheetName, 0);
if(sheet != null) {
// Write the output to a file
FileOutputStream fileOut = new FileOutputStream("workbook1.xls");
wb.write(fileOut);
fileOut.close();
}
} catch(FileNotFoundException fnfe) {
System.err.println(fnfe.getMessage());
} catch(IOException ioe) {
System.err.println(ioe.getMessage());
}
-----------------------
I expect due to the code an excel-file (workbook1.xls) like:
Sheet-Pos Name Content of cell(0,0)
----------------------------------------------
0 AdFS2 ""
1 Tabelle2 "Tabelle2"
2 Tabelle3 "Tabelle3"
----------------------------------------------
But the excel-file (workbook1.xls) is:
Sheet-Pos Name Content of cell(0,0)
----------------------------------------------
0 Tabelle2 "Tabelle3"
1 Tabelle3 ""
2 AdFS2 "Tabelle2"
----------------------------------------------
Is there a bug in both versions (2.0RC2 and 2.5.1) or have I done a
mistake in the code?
I am really confused!?!?
By the way: I know, in this simple example I could also make "HSSFRow
row = sheet.getRow(0); if(row != null) sheet.removeRow(row);", to get
the expected result, but this is not the solution in my really
functionality.
Thanks, Kind Regards
--
Oliver Hirschi
http://www.FamilyHirschi.ch
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
Mailing List: http://jakarta.apache.org/site/mail2.html#poi
The Apache Jakarta Poi Project: http://jakarta.apache.org/poi/