Ebeveyn Pivot Tablosunun İç İçe veya Alt Pivot Tablolarını Bulun ve Yenileyin
Contents
[
Hide
]
Olası Kullanım Senaryoları
Bazen bir pivot tablo, veri kaynağı olarak başka bir pivot tablo kullanır, bu nedenle buna alt pivot tablo veya iç içe pivot tablo denir. Bir üst pivot tablonun alt pivot tablolarını,PivotTable.GetChildren()yöntem.
Ebeveyn Pivot Tablosunun İç İçe veya Alt Pivot Tablolarını Bulun ve Yenileyin
Aşağıdaki örnek kod,örnek excel dosyası üç pivot tablo içerir. Alttaki iki pivot tablo, bu ekran görüntüsünde gösterildiği gibi yukarıdaki pivot tablonun çocuklarıdır. Kod, şunu kullanarak alt pivot tabloyu bulur:PivotTable.GetChildren()yöntemini kullanır ve ardından bunları birer birer yeniler.
Basit kod
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-.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(); | |
} |