aspose.cells

Class FormatConditionCollection

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

Example:

$workbook = new cells\Workbook();
$sheet = $workbook->getWorksheets()->get(0);
$index = $sheet->getConditionalFormattings()->add();
$fcs = $sheet->getConditionalFormattings()->get($index);
//Sets the conditional format range
$ca = new cells\CellArea();
$ca->StartRow = 0;
$ca->EndRow = 0;
$ca->StartColumn = 0;
$ca->EndColumn = 0;
$fcs->addArea($ca);
$ca = new cells\CellArea();
$ca->StartRow = 1;
$ca->EndRow = 1;
$ca->StartColumn = 1;
$ca->EndColumn = 1;
$fcs->addArea($ca);
//Adds condition
$conditionIndex = $fcs->addCondition(cells\FormatConditionType::CELL_VALUE, cells\OperatorType::BETWEEN, "=A2", "100");
//Adds condition
$conditionIndex2 = $fcs->addCondition(cells\FormatConditionType::CELL_VALUE, cells\OperatorType::BETWEEN, "50", "100");
//Sets the background color
$fc = $fcs->get($conditionIndex);
$fc->getStyle()->setBackgroundColor(cells\Color::getRed());

Property Getters/Setters Summary
functiongetCount()
Gets the count of the conditions.
functiongetRangeCount()
Gets count of conditionally formatted ranges.
functionget(index)
Gets the formatting condition by index.
 
Method Summary
functionadd(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 formatting.
functionaddArea(cellArea)
Adds a conditional formatted cell range.
functionaddCondition(type)
Add a format condition.
functionaddCondition(type, operatorType, formula1, formula2)
Adds a formatting condition.
functiongetCellArea(index)
Gets the conditional formatted cell range by index.
functionremoveArea(index)
Removes conditional formatted cell range by index.
functionremoveArea(startRow, startColumn, totalRows, totalColumns)
Remove conditional formatting int the range.
functionremoveCondition(index)
Removes the formatting condition by index.
 

    • Property Getters/Setters Detail

      • getCount : Number 

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

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

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

      • add

        function 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 formatting. OperatorType
        Parameters:
        cellArea: CellArea - Conditional formatted cell range.
        type: Number - A FormatConditionType value. Type of conditional formatting.It could be one of the members of FormatConditionType.
        operatorType: Number - 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

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

        function addCondition(type, operatorType, formula1, formula2)
        Adds a formatting condition.
        Parameters:
        type: Number - A FormatConditionType value. The type of format condition.
        operatorType: Number - A OperatorType value. The operator type
        formula1: String - The value or expression associated with conditional 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 conditional formatting. The input format is same with formula1
        Returns:
        Formatting condition object index;
      • addCondition

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

        function getCellArea(index)
        Gets the conditional formatted cell range by index.
        Parameters:
        index: Number - the index of the conditional formatted cell range.
        Returns:
        the conditional formatted cell range
      • removeArea

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

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

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