asposecells.api

Class FormatConditionCollection

Represents conditional formatting. The FormatConditions can contain up to three conditional formats.

Example:

# Adds an empty conditional formatting
workbook = Workbook()
sheet = workbook.getWorksheets().get(0)
index = sheet.getConditionalFormattings().add()
fcs = sheet.getConditionalFormattings().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)
# Adds condition.
conditionIndex = fcs.addCondition(FormatConditionType.CELL_VALUE, OperatorType.BETWEEN, "=A2", "100")
# Adds 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()
Gets the count of the conditions.
methodgetRangeCount()
Gets count of conditionally formatted ranges.
methodget(index)
Gets the formatting conidition by index.
 
Method Summary
methodadd(cellArea, type, operatorType, formula1, formula2)
Adds a formatting condition and effected cell rang to the FormatConditions The FormatConditions can contain up to three conditional formats. References to the other sheets are not allowed in the formulas of conditional formattin
methodaddArea(cellArea)
Adds a conditional formatted cell range.
methodaddCondition(type)
Add a format condition.
methodaddCondition(type, operatorType, formula1, formula2)
Adds a formatting condition.
methodgetCellArea(index)
Gets the conditional formatted cell range by index.
methodremoveArea(index)
Removes conditional formatted cell range by index.
methodremoveArea(startRow, startColumn, totalRows, totalColumns)
Remove conditional formatting int the range.
methodremoveCondition(index)
Removes the formatting condition by index.
 

    • Property Getters/Setters Detail

      • getCount : int 

        int getCount()
        
        Gets the count of the conditions.
      • getRangeCount : int 

        int getRangeCount()
        
        Gets count of conditionally formatted ranges.
      • get : FormatCondition 

        FormatCondition get(index)
        
        Gets the formatting conidition by index.
        Parameters:
        index - the index of the formatting conidition to return.
        Returns:
        the formatting conidition
    • Method Detail

      • add

        int[] add(cellArea, type, operatorType, formula1, formula2)
        Adds a formatting condition and effected cell rang to the FormatConditions The FormatConditions can contain up to three conditional formats. References to the other sheets are not allowed in the formulas of conditional formattin OperatorType
        Parameters:
        cellArea: CellArea - Conditional formatted cell range.
        type: int - A FormatConditionType value. Type of conditional formatting.It could be one of the members of FormatConditionType.
        operatorType: int - A OperatorType value. Comparison operator.It could be one of the members of OperatorType.
        formula1: String - The value or expression associated with conditional formatting.
        formula2: String - The value or expression associated with conditional formatting
        Returns:
        [0]:Formatting condition object index;[1] Effected cell rang index.
      • addArea

        int addArea(cellArea)
        Adds a conditional formatted cell range.
        Parameters:
        cellArea: CellArea - Conditional formatted cell range.
        Returns:
        Conditional formatted cell rang index.
      • addCondition

        int addCondition(type, operatorType, formula1, formula2)
        Adds a formatting condition.
        Parameters:
        type: int - A FormatConditionType value. of conditinal formatting.It could be one of the members of FormatConditionType.
        operatorType: int - A OperatorType value. The comparison OperatorType.It could be one of the members of OperatorType.
        formula1: String - The value or expression associated with conditinal formatting. If the input value starts with '=', then it will be taken as formula. Otherwise it will be taken as plain value(text, number, bool). For text value that starts with '=', user may input it as formula in format: "=\"=...\"".
        formula2: String - The value or expression associated with conditinal formatting. The input format is same with formula1
        Returns:
        Formatting condition object index;
      • addCondition

        int addCondition(type)
        Add a format condition.
        Parameters:
        type: int - A FormatConditionType value. Format condition type.
        Returns:
        Formatting condition object index;
      • getCellArea

        CellArea getCellArea(index)
        Gets the conditional formatted cell range by index.
        Parameters:
        index: int - the index of the coditional formatted cell range.
        Returns:
        the conditional formatted cell range
      • removeArea

         removeArea(index)
        Removes conditional formatted cell range by index.
        Parameters:
        index: int - The index of the conditional formatted cell range to be removed.
      • removeArea

        boolean removeArea(startRow, startColumn, totalRows, totalColumns)
        Remove conditional formatting int the range.
        Parameters:
        startRow: int - The startRow of the range.
        startColumn: int - The startColumn of the range.
        totalRows: int - The number of rows of the range.
        totalColumns: int - The number of columns of the range.
        Returns:
        Returns TRUE, this FormatCondtionCollection should be removed.
      • removeCondition

         removeCondition(index)
        Removes the formatting condition by index.
        Parameters:
        index: int - The index of the formatting condition to be removed.