Example:
$workbook = new cells\Workbook();
$sheet = $workbook->getWorksheets()->get(0);
//Adds an empty conditional formatting
$index = $sheet->getConditionalFormattings()->add();
$fcs = $sheet->getConditionalFormattings()->get($index);
//Sets the conditional format range
$ca = new cells\CellArea();
$ca->StartRow = 0;
$ca->EndRow = 2;
$ca->StartColumn = 0;
$ca->EndColumn = 0;
$fcs->addArea($ca);
//Adds condition
$idx = $fcs->addCondition(cells\FormatConditionType::DATA_BAR);
$fcs->addArea($ca);
$cond = $fcs->get($idx);
//Get Databar
$dataBar = $cond->getDataBar();
$dataBar->setColor(cells\Color::getOrange());
//Set Databar properties
$dataBar->getMinCfvo()->setType(cells\FormatConditionValueType::PERCENTILE);
$dataBar->getMinCfvo()->setValue(30);
$dataBar->setShowValue(false);
//Put Cell Values
$sheet->getCells()->get("A1")->putValue(10);
$sheet->getCells()->get("A2")->putValue(120);
$sheet->getCells()->get("A3")->putValue(260);
| Property Getters/Setters Summary | ||
|---|---|---|
function | getAxisColor() | |
function | setAxisColor(value) | |
| Gets the color of the axis for cells with conditional formatting as data bars. | ||
function | getAxisPosition() | |
function | setAxisPosition(value) | |
| Gets or sets the position of the axis of the data bars specified by a conditional formatting rule. The value of the property is DataBarAxisPosition integer constant. | ||
function | getBarBorder() | |
| Gets an object that specifies the border of a data bar. | ||
function | getBarFillType() | |
function | setBarFillType(value) | |
| Gets or sets how a data bar is filled with color. The value of the property is DataBarFillType integer constant. | ||
function | getColor() | |
function | setColor(value) | |
| Get or set this DataBar's Color. | ||
function | getDirection() | |
function | setDirection(value) | |
| Gets or sets the direction the databar is displayed. The value of the property is TextDirectionType integer constant. | ||
function | getMaxCfvo() | |
| Get or set this DataBar's max value object. Cannot set null or CFValueObject with type FormatConditionValueType.Min to it. | ||
function | getMaxLength() | |
function | setMaxLength(value) | |
| Represents the max length of data bar . | ||
function | getMinCfvo() | |
| Get or set this DataBar's min value object. Cannot set null or CFValueObject with type FormatConditionValueType.Max to it. | ||
function | getMinLength() | |
function | setMinLength(value) | |
| Represents the min length of data bar . | ||
function | getNegativeBarFormat() | |
| Gets the NegativeBarFormat object associated with a data bar conditional formatting rule. | ||
function | getShowValue() | |
function | setShowValue(value) | |
| Get or set the flag indicating whether to show the values of the cells on which this data bar is applied. Default value is true. | ||
| Method Summary | ||
|---|---|---|
function | toImage(cell, imgOpts) | |
| Render data bar in cell to image byte array. | ||
| Property Getters/Setters Detail |
|---|
getAxisColor/setAxisColor : Color | |
function getAxisColor() / function setAxisColor(value) | |
getAxisPosition/setAxisPosition : Number | |
function getAxisPosition() / function setAxisPosition(value) | |
getBarFillType/setBarFillType : Number | |
function getBarFillType() / function setBarFillType(value) | |
getDirection/setDirection : Number | |
function getDirection() / function setDirection(value) | |
getBarBorder : DataBarBorder | |
function getBarBorder() | |
getNegativeBarFormat : NegativeBarFormat | |
function getNegativeBarFormat() | |
getMinCfvo : ConditionalFormattingValue | |
function getMinCfvo() | |
getMaxCfvo : ConditionalFormattingValue | |
function getMaxCfvo() | |
getColor/setColor : Color | |
function getColor() / function setColor(value) | |
getMinLength/setMinLength : Number | |
function getMinLength() / function setMinLength(value) | |
getMaxLength/setMaxLength : Number | |
function getMaxLength() / function setMaxLength(value) | |
getShowValue/setShowValue : boolean | |
function getShowValue() / function setShowValue(value) | |
| Method Detail |
|---|
toImage | |
function toImage(cell, imgOpts) | |
cell: Cell - Indicate the data bar in which cell to be renderedimgOpts: ImageOrPrintOptions - ImageOrPrintOptions contains some property of output image