Tabellenblätter innerhalb der Arbeitsmappe neu anordnen

Aspose.Cells - Tabellenblätter innerhalb der Arbeitsmappe neu anordnen

Aspose.Cells bietet eine Methode, Worksheet.moveTo(), um ein Tabellenblatt in einer Tabelle an eine andere Stelle zu verschieben.

Java

 //Create a new Workbook.

Workbook workbook = new Workbook();

WorksheetCollection worksheets = workbook.getWorksheets();

Worksheet worksheet1 = worksheets.get(0);

Worksheet worksheet2 = worksheets.add("Sheet2");

Worksheet worksheet3 = worksheets.add("Sheet3");

//Move Sheets with in Workbook.

worksheet2.moveTo(0);

worksheet1.moveTo(1);

worksheet3.moveTo(2);

//Save the excel file.

workbook.save(dataDir + "AsposeMoveSheet.xls");

Apache POI SS - HSSF XSSF - Tabellenblätter innerhalb der Arbeitsmappe neu anordnen

Apache POI bietet die Methode Workbook.setSheetOrder(), um Tabellenblätter in der erforderlichen Reihenfolge festzulegen.

Java

 Workbook wb = new HSSFWorkbook();

wb.createSheet("new sheet");

wb.createSheet("second sheet");

wb.createSheet("third sheet");

wb.setSheetOrder("second sheet", 0);

wb.setSheetOrder("new sheet", 1);

wb.setSheetOrder("third sheet", 2);

FileOutputStream fileOut = new FileOutputStream(dataDir + "Apache_Reordered.xls");

wb.write(fileOut);

fileOut.close();

Laufenden Code herunterladen

Beispielcode herunterladen