تنسيق خلايا جدول البيانات المحورية
أحيانًا، ترغب في تنسيق خلايا جدول الدوران. على سبيل المثال، ترغب في تطبيق لون خلفية على خلايا جدول الدوران. Aspose.Cells لبرنامج Python via .NET يوفر طريقتين PivotTable.format_all(style) و PivotTable.format(row, column, style) يمكنك استخدامهما لهذا الغرض.
PivotTable.format_all(style) تطبق النمط على جدول المحور بأكمله بينما PivotTable.format(row, column, style) يطبق النمط على خلية واحدة في جدول المحور.
from aspose.cells import BackgroundType, Workbook | |
from aspose.pydrawing import Color | |
# Create workbook object from source file containing pivot table | |
workbook = Workbook("pivot_format.xlsx") | |
# Access the worksheet by its name | |
worksheet = workbook.worksheets.get("Sheet1") | |
# Access the pivot table | |
pivotTable = worksheet.pivot_tables[1] | |
# Create a style object with background color light blue | |
style = workbook.create_style() | |
style.pattern = BackgroundType.SOLID | |
style.background_color = Color.light_blue | |
# Format entire pivot table with light blue color | |
pivotTable.format_all(style) | |
# Create another style object with yellow color | |
style = workbook.create_style() | |
style.pattern = BackgroundType.SOLID | |
style.background_color = Color.yellow | |
# Access the pivot table | |
pivotTable2 = worksheet.pivot_tables[0] | |
# Format the cell of pivot table | |
pivotTable2.format(16, 5, style) | |
# Save the workbook object | |
workbook.save("out.xlsx") |