إخفاء البيانات وفرزها في جدول البيانات المحوري

إخفاء جدول الدوران وفرز البيانات باستخدام Aspose.Cells لمكتبة Python Excel

Aspose.Cells لـ Python via .NET تدعم إخفاء البيانات وترتيبها في جدول الدوران. يظهر الكود التالي كيف يمكن فرز عمود الدرجات تنازليًا ثم إخفاء الصفوف التي تحتوي على درجة أقل من 60.

from aspose.cells import Workbook
# directories
sourceDir = RunExamples.Get_SourceDirectory()
outputDir = RunExamples.Get_OutputDirectory()
workbook = Workbook(sourceDir + "PivotTableHideAndSortSample.xlsx")
worksheet = workbook.worksheets[0]
pivotTable = worksheet.pivot_tables[0]
dataBodyRange = pivotTable.data_body_range
currentRow = 3
rowsUsed = dataBodyRange.end_row
# Sorting score in descending
field = pivotTable.row_fields[0]
field.is_auto_sort = True
field.is_ascend_sort = False
field.auto_sort_field = 0
pivotTable.refresh_data()
pivotTable.calculate_data()
# Hiding rows with score less than 60
while currentRow < rowsUsed:
cell = worksheet.cells.get(currentRow, 1)
score = float(cell.value)
if score < 60:
worksheet.cells.hide_row(currentRow)
currentRow
currentRow = currentRow + 1
pivotTable.refresh_data()
pivotTable.calculate_data()
# Saving the Excel file
workbook.save(outputDir + "PivotTableHideAndSort_out.xlsx")

الملفات الإكسل المصدرية والناتجة المستخدمة في مقتطف الكود مرفقة للرجوع إليها.

ملف المصدر

ملف الناتج