FormatConditionCollection klass

FormatConditionCollection klass

Representerar villkorlig formatering. Formatvillkoren kan innehålla upp till tre villkorliga format.

Typen FormatConditionCollection avslöjar följande medlemmar:

Egenskaper

Fast egendomBeskrivning
countFår räkningen av villkoren.
range_countHämtar antalet villkorligt formaterade intervall.

Hämtar formateringsvillkoret efter index.

Indexerare

namnBeskrivning
[index]indexet för formateringsvillkoret som ska returneras.

Metoder

MetodBeskrivning
add_conditionLägger till ett formateringsvillkor.
add_conditionLägg till ett formatvillkor.
remove_areaTar bort villkorligt formaterat cellintervall efter index.
remove_areaTa bort villkorlig formatering i intervallet.
addLägger till ett formateringsvillkor och påverkad cellring till FormatConditions
Formatvillkoren kan innehålla upp till tre villkorliga format.
Referenser till de andra arken är inte tillåtna i formlerna för villkorlig formatering.
add_areaLägger till ett villkorligt formaterat cellintervall.
get_cell_areaHämtar det villkorligt formaterade cellintervallet efter index.
remove_conditionTar bort formateringsvillkoret genom index.

Exempel

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

Se även