FormatConditionCollection classe

FormatConditionCollection classe

Représente la mise en forme conditionnelle. Les FormatConditions peuvent contenir jusqu’à trois formats conditionnels.

Le type FormatConditionCollection expose les membres suivants :

Propriétés

PropriétéDescription
countObtient le nombre de conditions.
range_countObtient le nombre de plages formatées conditionnellement.

Obtient la condition de formatage par index.

Indexeur

NomDescription
[index]l’index de la condition de formatage à renvoyer.

Méthodes

MéthodeDescription
add_condition(self, type, operator_type, formula1, formula2)Ajoute une condition de formatage.
add_condition(self, type)Ajouter une condition de format.
remove_area(self, index)Supprime la plage de cellules formatées conditionnellement par index.
remove_area(self, start_row, start_column, total_rows, total_columns)Supprimer la mise en forme conditionnelle dans la plage.
add(self, cell_area, type, operator_type, formula1, formula2)Ajoute une condition de formatage et une plage de cellules affectée aux FormatConditions
Les FormatConditions peuvent contenir jusqu’à trois formats conditionnels.
Les références aux autres feuilles ne sont pas autorisées dans les formules de mise en forme conditionnelle.
add_area(self, cell_area)Ajoute une plage de cellules formatées conditionnellement.
get_cell_area(self, index)Obtient la plage de cellules formatée conditionnellement par index.
remove_condition(self, index)Supprime la condition de formatage par index.

Exemple

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")

Voir également