2 Renkli Ölçek ve 3 Renkli Ölçek Koşullu Biçimlendirmeleri Ekle
Contents
[
Hide
]
2- Renkli Ölçek ve 3- Renkli Ölçek Koşullu Biçimlendirmeleri aynı şekilde eklenir, ancak FormatCondition.color_scale.is_3_color_scale özelliği ile farklılaşırlar. Bu özellik, 2- Renkli Ölçek için false, 3- Renkli Ölçek Koşullu Biçimlendirme için true‘dir.
Aşağıdaki örnek kod, 2- Renkli ve 3- Renkli Ölçek Koşullu Biçimlendirmeleri ekler. çıktı excel dosyasını oluşturur.
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") |