親ピボットテーブルのネストされたピボットテーブルや子ピボットテーブルを見つけて更新する
Contents
[
Hide
]
可能な使用シナリオ
親ピボットテーブルが別のピボットテーブルをデータソースとして使用する場合、それを子ピボットテーブルやネストされたピボットテーブルと呼びます。PivotTable.getChildren()を使用して親ピボットテーブルの子ピボットテーブルを見つけることができます。
親ピボットテーブルのネストされたピボットテーブルや子ピボットテーブルを見つけて更新する
次のサンプルコードは、3つのピボットテーブルを含むsample Excel fileをロードします。下の2つのピボットテーブルは、スクリーンショットに示すように、上記のピボットテーブルの子供です。コードはPivotTable.getChildren()メソッドを使用して子のピボットテーブルを見つけ、それらを1つずつ更新します。
サンプルコード
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
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-Java | |
//Load sample Excel file | |
Workbook wb = new Workbook("sampleFindAndRefreshNestedOrChildrenPivotTables.xlsx"); | |
//Access first worksheet | |
Worksheet ws = wb.getWorksheets().get(0); | |
//Access third pivot table | |
PivotTable ptParent = ws.getPivotTables().get(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(); | |
} |