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 | ||
---|---|---|
function | getCount() | |
Gets the count of the conditions.
|
||
function | getRangeCount() | |
Gets count of conditionally formatted ranges.
|
||
function | get(index) | |
Gets the formatting condition by index.
|
Method Summary | ||
---|---|---|
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.
|
||
function | addArea(cellArea) | |
Adds a conditional formatted cell range.
|
||
function | addCondition(type) | |
Add a format condition.
|
||
function | addCondition(type, operatorType, formula1, formula2) | |
Adds a formatting condition.
|
||
function | getCellArea(index) | |
Gets the conditional formatted cell range by index.
|
||
function | removeArea(index) | |
Removes conditional formatted cell range by index.
|
||
function | removeArea(startRow, startColumn, totalRows, totalColumns) | |
Remove conditional formatting int the range.
|
||
function | removeCondition(index) | |
Removes the formatting condition by index.
|
function getCount()
function getRangeCount()
function get(index)
index
- the index of the formatting condition to return.function add(cellArea, type, operatorType, formula1, formula2)
cellArea: CellArea
- Conditional formatted cell range.type: Number
- A operatorType: Number
- A formula1: String
- The value or expression associated with conditional formatting.formula2: String
- The value or expression associated with conditional formattingfunction addArea(cellArea)
cellArea: CellArea
- Conditional formatted cell range.function addCondition(type, operatorType, formula1, formula2)
type: Number
- A operatorType: Number
- A 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 formula1function addCondition(type)
type: Number
- A function getCellArea(index)
index: Number
- the index of the conditional formatted cell range.function removeArea(index)
index: Number
- The index of the conditional formatted cell range to be removed.function removeArea(startRow, startColumn, totalRows, totalColumns)
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.function removeCondition(index)
index: Number
- The index of the formatting condition to be removed.