العمل مع تنسيقات عرض البيانات لحقل البيانات في جدول الإحصائيات المحورية

“ترتيب من الأصغر إلى الأكبر” و “ترتيب من الأكبر إلى الأصغر” خيار شكل العرض

يوفر ASpose.Cells القدرة على تعيين خيار تنسيق العرض لحقول الجدول المحوري. لهذا، توفر واجهة برمجة التطبيقات العقارية PivotField.DataDisplayFormat. لتحديد الترتيب من الأكبر إلى الأصغر، قد تقوم بتعيين خاصية PivotField.DataDisplayFormat إلى PivotFieldDataDisplayFormat.RankLargestToSmallest. المقتطف البرمجي التالي يوضح ضبط خيارات تنسيق العرض.

يمكن تنزيل ملفات الأصل والإخراج العينية من هنا لاختبار كود العينة:

ملف إكسل المصدر

ملف إكسل الإخراج

// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET
// directories
string sourceDir = RunExamples.Get_SourceDirectory();
string outputDir = RunExamples.Get_OutputDirectory();
// Load a template file
Workbook workbook = new Workbook(sourceDir + "PivotTableSample.xlsx");
// Get the first worksheet
Worksheet worksheet = workbook.Worksheets[0];
int pivotIndex = 0;
// Accessing the PivotTable
PivotTable pivotTable = worksheet.PivotTables[pivotIndex];
// Accessing the data fields.
PivotFieldCollection pivotFields = pivotTable.DataFields;
// Accessing the first data field in the data fields.
PivotField pivotField = pivotFields[0];
// Setting data display format
pivotField.ShowValuesSetting.CalculationType = PivotFieldDataDisplayFormat.RankLargestToSmallest;
pivotTable.CalculateData();
// Saving the Excel file
workbook.Save(outputDir + "PivotTableDataDisplayFormatRanking_out.xlsx");