aspose.cells

Class ConditionalFormattingCollection

Encapsulates a collection of FormatCondition objects.

Example:

$workbook = new cells\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 = 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);
//Add condition
$conditionIndex = $fcs->addCondition(cells\FormatConditionType::CELL_VALUE, cells\OperatorType::BETWEEN, "=A2", "100");
//Add 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()
functionget(index)
Gets the FormatConditions element at the specified index.
 
Method Summary
functionadd()
Adds a FormatConditions to the collection.
functionadd(value)
Reserved for internal use.
functionclear()
functioncontains(value)
Reserved for internal use.
functioncopy(cfs)
Copies conditional formatting.
functionget(index)
Reserved for internal use.
functionindexOf(value)
Reserved for internal use.
functioniterator()
functionremoveArea(startRow, startColumn, totalRows, totalColumns)
Remove all conditional formatting in the range.
functionremoveAt(index)
 

    • Property Getters/Setters Detail

      • getCount : Number 

        function getCount()
        
      • get : FormatConditionCollection 

        function get(index)
        
        Gets the FormatConditions element at the specified index.
        Parameters:
        index - The zero based index of the element.
    • Method Detail

      • removeArea

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

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

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

        function clear()
      • removeAt

        function removeAt(index)
      • iterator

        function iterator()
      • get

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

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

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

        function indexOf(value)
        Reserved for internal use.