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

可能な使用シナリオ

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

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

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

todo:image_alt_text

サンプルコード

// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET
//Load sample Excel file
Workbook wb = new Workbook("sampleFindAndRefreshNestedOrChildrenPivotTables.xlsx");
//Access first worksheet
Worksheet ws = wb.Worksheets[0];
//Access third pivot table
PivotTable ptParent = ws.PivotTables[2];
//Access the children of the parent pivot table
PivotTable[] ptChildren = ptParent.GetChildren();
//Refresh all the children pivot table
int count = ptChildren.Length;
for (int idx = 0; idx < count; idx++)
{
//Access the child pivot table
PivotTable ptChild = ptChildren[idx];
//Refresh the child pivot table
ptChild.RefreshData();
ptChild.CalculateData();
}