Pivot Tabelle aus einem Arbeitsblatt löschen

Wie man Pivot-Tabelle aus Arbeitsblatt mithilfe von Aspose.Cells für Python Excel-Bibliothek löscht

Der folgende Beispielcode löscht zwei Pivot-Tabellen aus dem Arbeitsblatt. Zuerst entfernt er die Pivot-Tabelle unter Verwendung der Worksheet.pivot_tables.remove(pivot_table)-Methode und dann entfernt er die Pivot-Tabelle unter Verwendung der Worksheet.pivot_tables.remove_at(index, keep_data)-Methode

from aspose.cells import Workbook
# For complete examples and data files, please go to https:# github.com/aspose-cells/Aspose.Cells-for-.NET
# The path to the documents directory.
dataDir = RunExamples.GetDataDir(".")
# Create workbook object from source Excel file
workbook = Workbook(dataDir + "source.xlsx")
# Access the first worksheet
worksheet = workbook.worksheets[0]
# Access the first pivot table object
pivotTable = worksheet.pivot_tables[0]
# Remove pivot table using pivot table object
worksheet.pivot_tables.remove(pivotTable)
# OR you can remove pivot table using pivot table position by uncommenting below line
# worksheet.PivotTables.RemoveAt(0);
# Save the workbook
workbook.save(dataDir + "output_out.xlsx")