العمل مع تنسيقات عرض البيانات لحقل البيانات في جدول الإحصائيات المحورية
“ترتيب من الأصغر إلى الأكبر” و “ترتيب من الأكبر إلى الأصغر” خيار شكل العرض
توفر Aspose.Cells القدرة على تعيين خيار شكل العرض لحقول الجدول المحوري. لهذا الغرض، يوفر الواجهة البرمجية الخاصية PivotField.DataDisplayFormat. لتصنيف من الأكبر إلى الأصغر، يمكنك تعيين الخاصية PivotField.DataDisplayFormat على PivotFieldDataDisplayFormat.RANK_LARGEST_TO_SMALLEST. كود البرنامج التالي يوضح كيفية تعيين خيارات شكل العرض.
يمكن تنزيل ملفات الأصل والإخراج العينية من هنا لاختبار كود العينة:
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-Java | |
// directories | |
String sourceDir = Utils.Get_SourceDirectory(); | |
String outputDir = Utils.Get_OutputDirectory(); | |
// Load a template file | |
Workbook workbook = new Workbook(sourceDir + "PivotTableSample.xlsx"); | |
// Get the first worksheet | |
Worksheet sheet = workbook.getWorksheets().get(0); | |
int pivotIndex = 0; | |
// Get the pivot tables in the sheet | |
PivotTable pivotTable = sheet.getPivotTables().get(pivotIndex); | |
// Accessing the data fields. | |
PivotFieldCollection pivotFields = pivotTable.getDataFields(); | |
// Accessing the first data field in the data fields. | |
PivotField pivotField = pivotFields.get(0); | |
// Setting data display format | |
pivotField.setDataDisplayFormat(PivotFieldDataDisplayFormat.RANK_LARGEST_TO_SMALLEST); | |
pivotTable.calculateData(); | |
// Saving the Excel file | |
workbook.save(outputDir + "PivotTableDataDisplayFormatRanking_out.xlsx"); |