العثور وتحديث جداول الدوران المدمجة أو الفرعية لجدول الدوران الأم

سيناريوهات الاستخدام المحتملة

في بعض الأحيان، يستخدم جدول دوران واحد جدول دوران آخر كمصدر بيانات، لذا يطلق عليه جدول دوران فرعي أو مدمج. يمكنك العثور على جداول الدوران الفرعية لجدول دوران أم باستخدام الطريقة PivotTable.GetChildren().

العثور وتحديث جداول الدوران المدمجة أو الفرعية لجدول الدوران الأم

يحمل رمز العينة التالي ملف إكسل المثالي الذي يحتوي على ثلاثة جداول دوران. الجداول الدوران السفلية هي أطفال الجدول الدوران العلوي كما هو موضح في هذه اللقطة من الشاشة. يعثر الكود على جدول الدوران الفرعي باستخدام الطريقة 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();
}