Last active
November 13, 2025 16:46
-
-
Save aspose-com-gists/64960a62d4daf2c43ef35d28e3497297 to your computer and use it in GitHub Desktop.
How to Delete Pivot Table from Excel Sheet in Python
This file contains hidden or 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
| 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