asposecells.api

Class ConditionalFormattingCollection

Encapsulates a collection of FormatCondition objects.

Example:

# Instantiating a Workbook object
workbook = Workbook()
sheet = workbook.getWorksheets().get(0)
# Get Conditional Formattings
cformattings = sheet.getConditionalFormattings()
# Adds an empty conditional formatting
index = cformattings.add()
# Get newly added Conditional formatting
fcs = cformattings.get(index)
# Sets the conditional format range.
ca = CellArea()
ca.StartRow = 0
ca.EndRow = 0
ca.StartColumn = 0
ca.EndColumn = 0
fcs.addArea(ca)
ca = CellArea()
ca.StartRow = 1
ca.EndRow = 1
ca.StartColumn = 1
ca.EndColumn = 1
fcs.addArea(ca)
# Add condition.
conditionIndex = fcs.addCondition(FormatConditionType.CELL_VALUE, OperatorType.BETWEEN, "=A2", "100")
# Add condition.
conditionIndex2 = fcs.addCondition(FormatConditionType.CELL_VALUE, OperatorType.BETWEEN, "50", "100")
# Sets the background color.
fc = fcs.get(conditionIndex)
fc.getStyle().setBackgroundColor(Color.getRed())
# Saving the Excel file
workbook.save("Book1.xls")

Property Getters/Setters Summary
methodgetCount()
methodget(index)
Gets the FormatConditions element at the specified index.
 
Method Summary
methodadd()
Adds a FormatConditions to the collection.
methodadd(value)
Reserved for internal use.
methodclear()
methodcontains(value)
Reserved for internal use.
methodcopy(cfs)
Copies conditional formatting.
methodget(index)
Reserved for internal use.
methodindexOf(value)
Reserved for internal use.
methoditerator()
methodremoveArea(startRow, startColumn, totalRows, totalColumns)
Remove all conditional formatting in the range.
methodremoveAt(index)
 

    • Property Getters/Setters Detail

      • getCount : int 

        int getCount()
        
    • Method Detail

      • removeArea

         removeArea(startRow, startColumn, totalRows, totalColumns)
        Remove all conditional formatting in the range.
        Parameters:
        startRow: int - The start row of the range.
        startColumn: int - The start column of the range.
        totalRows: int - The number of rows of the range.
        totalColumns: int - The number of columns of the range.
      • copy

         copy(cfs)
        Copies conditional formatting.
        Parameters:
        cfs: ConditionalFormattingCollection - The conditional formatting
      • add

        int add()
        Adds a FormatConditions to the collection.
        Returns:
        FormatConditions object index.
      • clear

         clear()
      • removeAt

         removeAt(index)
      • iterator

        Iterator iterator()
      • get

        Object get(index)
        Reserved for internal use.
      • contains

        boolean contains(value)
        Reserved for internal use.
      • add

        int add(value)
        Reserved for internal use.
      • indexOf

        int indexOf(value)
        Reserved for internal use.