العمل مع تنسيقات عرض البيانات لحقل البيانات في جدول الإحصائيات المحورية
كيفية تعيين خيار “تصنيفات من الأصغر إلى الأكبر” و “تصنيفات من الأكبر إلى الأصغر” لخيار صيغة العرض
Aspose.Cells for Python via .NET يوفر القدرة على تعيين خيارات صيغة العرض لحقول Pivot. لهذا، يقدم الواجهة البرمجية الخاصية PivotField.data_display_format. لتصنيف من الأكبر إلى الأصغر، يمكنك تعيين الخاصية PivotField.data_display_format إلى PivotFieldDataDisplayFormat.RANK_LARGEST_TO_SMALLEST. يوضح مقتطف الكود التالي تعيين خيارات صيغة العرض.
يمكن تنزيل ملفات الأصل والإخراج العينية من هنا لاختبار كود العينة:
from aspose.cells import Workbook | |
from aspose.cells.pivot import PivotFieldDataDisplayFormat | |
# For complete examples and data files, please go to https:# github.com/aspose-cells/Aspose.Cells-for-.NET | |
# directories | |
sourceDir = RunExamples.Get_SourceDirectory() | |
outputDir = RunExamples.Get_OutputDirectory() | |
# Load a template file | |
workbook = Workbook(sourceDir + "PivotTableSample.xlsx") | |
# Get the first worksheet | |
worksheet = workbook.worksheets[0] | |
pivotIndex = 0 | |
# Accessing the PivotTable | |
pivotTable = worksheet.pivot_tables[pivotIndex] | |
# Accessing the data fields. | |
pivotFields = pivotTable.data_fields | |
# Accessing the first data field in the data fields. | |
pivotField = pivotFields[0] | |
# Setting data display format | |
pivotField.data_display_format = PivotFieldDataDisplayFormat.RANK_LARGEST_TO_SMALLEST | |
pivotTable.calculate_data() | |
# Saving the Excel file | |
workbook.save(outputDir + "PivotTableDataDisplayFormatRanking_out.xlsx") |