احصل على كائن Cell بواسطة DisplayName الخاص بـ PivotField of PivotTable

احصل على كائن Cell بواسطة DisplayName الخاص بـ PivotField of PivotTable

يصل الكود التالي إلى الجدول المحوري الأول من ورقة العمل ثم يحصل على الخلية حسب اسم العرض لحقل البيانات الثاني للجدول المحوري. ثم يغير لون التعبئة ولون الخط للخلية إلى الأزرق الفاتح والأسود على التوالي. تظهر لقطات الشاشة أدناه كيف يبدو الجدول المحوري قبل وبعد تنفيذ الكود.

الجدول المحوري - قبل ذلك
ما يجب القيام به: image_بديل_نص
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
// Create workbook object from source excel file
Workbook workbook = new Workbook(dataDir + "source.xlsx");
// Access first worksheet
Worksheet worksheet = workbook.Worksheets[0];
// Access first pivot table inside the worksheet
PivotTable pivotTable = worksheet.PivotTables[0];
// Access cell by display name of 2nd data field of the pivot table
Cell cell = pivotTable.GetCellByDisplayName(pivotTable.DataFields[0].DisplayName);
// Access cell style and set its fill color and font color
Style style = cell.GetStyle();
style.ForegroundColor = Color.LightBlue;
style.Font.Color = Color.Black;
// Set the style of the cell
pivotTable.Format(cell.Row, cell.Column, style);
// Save workbook
workbook.Save(dataDir + "output_out.xlsx");
الجدول المحوري - بعد
ما يجب القيام به: image_بديل_نص