親ピボットテーブルのネストされたピボットテーブルや子ピボットテーブルを見つけて更新する

可能な使用シナリオ

親ピボットテーブルが別のピボットテーブルをデータソースとして使用する場合、それを子ピボットテーブルやネストされたピボットテーブルと呼びます。PivotTable.get_children()を使用して親ピボットテーブルの子ピボットテーブルを見つけることができます。

親ピボットテーブルのネストされたまたは子供のピボットテーブルを検出および更新する方法

次のサンプルコードでは、3つのピボットテーブルを含むサンプルExcelファイルをロードし、その下の2つのピボットテーブルが、このスクリーンショットに示すように、上記のピボットテーブルの子であることを示しています。コードは、PivotTable.get_children()を使用して子ピボットテーブルを見つけ、それぞれを更新します。

todo:image_alt_text

サンプルコード

from aspose.cells import Workbook
# For complete examples and data files, please go to https:# github.com/aspose-cells/Aspose.Cells-for-.NET
# Load sample Excel file
wb = Workbook("sampleFindAndRefreshNestedOrChildrenPivotTables.xlsx")
# Access first worksheet
ws = wb.worksheets[0]
# Access third pivot table
ptParent = ws.pivot_tables[2]
# Access the children of the parent pivot table
ptChildren = ptParent.get_children()
# Refresh all the children pivot table
count = len(ptChildren)
for idx in range(count):
# Access the child pivot table
ptChild = ptChildren[idx]
# Refresh the child pivot table
ptChild.refresh_data()
ptChild.calculate_data()