Pivot Tabelle aus einem Arbeitsblatt löschen
Contents
[
Hide
]
Aspose.Cells bietet die Möglichkeit, eine Pivot-Tabelle aus einem Arbeitsblatt zu löschen oder zu entfernen. Sie können die Pivot-Tabelle mithilfe des Pivot-Tabellenobjekts oder der Position der Pivot-Tabelle löschen. Verwenden Sie bitte die Methode Worksheet.getPivotTables().remove(), um die Pivot-Tabelle mithilfe des Pivot-Tabellenobjekts zu löschen, und die Methode Worksheet.getPivotTables().removeAt(), um ein Pivot-Tabellenobjekt anhand seiner Position innerhalb der Pivot-Tabelle-Sammlung zu löschen.
Beispiel
Der folgende Beispielcode löscht zwei Pivot-Tabellen aus dem Arbeitsblatt. Zunächst wird die Pivot-Tabelle mithilfe der Methode Worksheet.getPivotTables().remove() entfernt und dann wird die Pivot-Tabelle mithilfe der Methode Worksheet.getPivotTables().removeAt() gelöscht
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-Java | |
// The path to the documents directory. | |
String dataDir = Utils.getDataDir(DeletePivotTableFromWorksheet.class); | |
// Create workbook object from source Excel file | |
Workbook workbook = new Workbook(dataDir + "sample.xlsx"); | |
// Access the first worksheet | |
Worksheet worksheet = workbook.getWorksheets().get(0); | |
// Access the first pivot table object | |
PivotTable pivotTable = worksheet.getPivotTables().get(0); | |
// Remove pivot table using pivot table object | |
worksheet.getPivotTables().remove(pivotTable); | |
// Remove pivot table using pivot table position | |
worksheet.getPivotTables().removeAt(0); | |
// Save the workbook | |
workbook.save(dataDir + "output.xlsx"); |