ワークシートからのピボットテーブルの削除
Contents
[
Hide
]
Aspose.Cells for Python via .NETでは、ワークシートからPivot Tableを削除または削除する機能が提供されます。ピボットテーブルオブジェクトまたはピボットテーブルの位置を使用してピボットテーブルを削除できます。ピボットテーブルオブジェクトを使用してピボットテーブルを削除するにはWorksheet.pivot_tables.remove(pivot_table)メソッドを使用し、ピボットテーブルのポジションでピボットテーブルオブジェクトを削除するにはWorksheet.pivot_tables.remove_at(index, keep_data)メソッドを使用してください。
Aspose.Cells for Python Excelライブラリを使用したワークシートからピボットテーブルを削除する方法
次のサンプルコードでは、ワークシートから2つのピボットテーブルを削除する方法が示されています。最初にWorksheet.pivot_tables.remove(pivot_table)メソッドを使用してピボットテーブルを削除し、次にWorksheet.pivot_tables.remove_at(index, keep_data)メソッドを使用してピボットテーブルを削除します。
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
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") |