Skip to content

Instantly share code, notes, and snippets.

@aspose-com-gists
Last active November 13, 2025 16:46
Show Gist options
  • Select an option

  • Save aspose-com-gists/64960a62d4daf2c43ef35d28e3497297 to your computer and use it in GitHub Desktop.

Select an option

Save aspose-com-gists/64960a62d4daf2c43ef35d28e3497297 to your computer and use it in GitHub Desktop.
How to Delete Pivot Table from Excel Sheet in Python
from aspose.cells import Workbook
# Load the Excel workbook
workbook = Workbook("sample1.xlsx")
# Access the first worksheet
worksheet = workbook.worksheets[0]
# Access the Pivot Table collection
pivot_tables = worksheet.pivot_tables
# Access the Pivot Table
pivot_table = worksheet.pivot_tables[0]
# Remove the first Pivot Table
pivot_tables.remove_pivot_table(pivot_table)
# Save the updated workbook
workbook.save("pivot_table_deleted.xlsx")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment