Ana Pivot Tablosunun İçindeki Yerleşik veya Çocuk Pivot Tablolarını Bul ve Yenile
Olası Kullanım Senaryoları
Bazı durumlarda, bir pivot tablosu diğer bir pivot tablosunu veri kaynağı olarak kullandığı için buna çocuk pivot tablosu veya yerleşik pivot tablosu denir. PivotTable.GetChildren() yöntemi kullanarak bir ana pivot tablosunun çocuk pivot tablolarını bulabilirsiniz.
Ana Pivot Tablosunun İçindeki Yerleşik veya Çocuk Pivot Tablolarını Bul ve Yenile
Aşağıdaki örnek kod, üç pivot tablosunu içeren örnek Excel dosyasını yükler. Alt iki pivot tablosu yukarıdaki pivot tablosunun alt pivot tablolarıdır ve bu ekran görüntüsünde gösterildiği gibi. Kod, PivotTable.GetChildren() yöntemini kullanarak alt pivot tablosunu bulur ve ardından birer birer yeniler.
Örnek Kod
// 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(); | |
} |