إضافة التدرج اللوني ثنائي اللون والثلاثي اللون وتنسيقهما الشرطي
Contents
[
Hide
]
إضافة الدالة المشروطة بمقياسي لون ومقياس اللون الثلاثي تمت إضافتهم بنفس الطريقة باستثناء اختلافهم في خاصية FormatCondition.color_scale.is_3_color_scale. يكون هذه الخاصية false لـ مقياس اللون المزدوج و true لـ مقياس اللون الثلاثي للدوال المشروطة.
يقوم الكود العيني التالي بإضافة الدوال المشروطة بمقياسي اللون والدالة المشروطة بمقياس اللون الثلاثي. يولد ملف الإكسيل الناتج.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from aspose.cells import CellArea, FormatConditionType, Workbook | |
from aspose.pydrawing import Color | |
# For complete examples and data files, please go to https:# github.com/aspose-cells/Aspose.Cells-for-.NET | |
# The path to the documents directory. | |
dataDir = RunExamples.GetDataDir(".") | |
# Create workbook | |
workbook = Workbook() | |
# Access first worksheet | |
worksheet = workbook.worksheets[0] | |
# Add some data in cells | |
worksheet.cells.get("A1").put_value("2-Color Scale") | |
worksheet.cells.get("D1").put_value("3-Color Scale") | |
for i in range(2, 15 + 1): | |
worksheet.cells.get("A" + str(i)).put_value(i) | |
worksheet.cells.get("D" + str(i)).put_value(i) | |
# Adding 2-Color Scale Conditional Formatting | |
ca = CellArea.create_cell_area("A2", "A15") | |
idx = worksheet.conditional_formattings.add() | |
fcc = worksheet.conditional_formattings[idx] | |
fcc.add_condition(FormatConditionType.COLOR_SCALE) | |
fcc.add_area(ca) | |
fc = worksheet.conditional_formattings[idx][0] | |
fc.color_scale.is_3_color_scale = False | |
fc.color_scale.max_color = Color.light_blue | |
fc.color_scale.min_color = Color.light_green | |
# Adding 3-Color Scale Conditional Formatting | |
ca = CellArea.create_cell_area("D2", "D15") | |
idx = worksheet.conditional_formattings.add() | |
fcc = worksheet.conditional_formattings[idx] | |
fcc.add_condition(FormatConditionType.COLOR_SCALE) | |
fcc.add_area(ca) | |
fc = worksheet.conditional_formattings[idx][0] | |
fc.color_scale.is_3_color_scale = True | |
fc.color_scale.max_color = Color.light_blue | |
fc.color_scale.mid_color = Color.yellow | |
fc.color_scale.min_color = Color.light_green | |
# Save the workbook | |
workbook.save(dataDir + "output_out.xlsx") |