FormatConditionCollection Klasse

FormatConditionCollection Klasse

Stellt bedingte Formatierung dar. Die FormatConditions können bis zu drei bedingte Formate enthalten.

Der Typ FormatConditionCollection macht die folgenden Member verfügbar:

Eigenschaften

EigentumBeschreibung
countRuft die Anzahl der Bedingungen ab.
range_countRuft die Anzahl der bedingt formatierten Bereiche ab.

Ruft die Formatierungsbedingung nach Index ab.

Indexer

NameBeschreibung
[index]Der Index der zurückzugebenden Formatierungsbedingung.

Methoden

MethodeBeschreibung
add_conditionFügt eine Formatierungsbedingung hinzu.
add_conditionFügen Sie eine Formatbedingung hinzu.
remove_areaEntfernt bedingt formatierte Zellbereiche nach Index.
remove_areaEntfernen Sie die bedingte Formatierung im Bereich.
addFügt den FormatConditions eine Formatierungsbedingung und einen betroffenen Zellbereich hinzu
Die FormatConditions können bis zu drei bedingte Formate enthalten.
Verweise auf die anderen Blätter sind in den Formeln der bedingten Formatierung nicht zulässig.
add_areaFügt einen bedingt formatierten Zellbereich hinzu.
get_cell_areaRuft den bedingt formatierten Zellbereich nach Index ab.
remove_conditionEntfernt die Formatierungsbedingung nach Index.

Beispiel

from aspose.cells import CellArea, FormatConditionType, OperatorType, Workbook
from aspose.pydrawing import Color

# Create a new Workbook.
workbook = Workbook()
# Get the first worksheet.
sheet = workbook.worksheets[0]
# Adds an empty conditional formatting
index = sheet.conditional_formattings.add()
fcs = sheet.conditional_formattings[index]
# Sets the conditional format range.
ca = CellArea()
ca.start_row = 0
ca.end_row = 0
ca.start_column = 0
ca.end_column = 0
fcs.add_area(ca)
ca = CellArea()
ca.start_row = 1
ca.end_row = 1
ca.start_column = 1
ca.end_column = 1
fcs.add_area(ca)
# Adds condition.
conditionIndex = fcs.add_condition(FormatConditionType.CELL_VALUE, OperatorType.BETWEEN, "=A2", "100")
# Adds condition.
conditionIndex2 = fcs.add_condition(FormatConditionType.CELL_VALUE, OperatorType.BETWEEN, "50", "100")
# Sets the background color.
fc = fcs[conditionIndex]
fc.style.background_color = Color.red
# Saving the Excel file
workbook.save("output.xls")

Siehe auch