DataBar

DataBar class

Describe the DataBar conditional formatting rule. This conditional formatting rule displays a gradated data bar in the range of cells.

class DataBar;

Example

const { Workbook, CellArea, Color, FormatConditionType, FormatConditionValueType } = require("aspose.cells.node");

//Instantiating a Workbook object
var workbook = new Workbook();
var sheet = workbook.worksheets.get(0);

//Adds an empty conditional formatting
var index = sheet.conditionalFormattings.add();
var fcs = sheet.conditionalFormattings.get(index);

//Sets the conditional format range.
var ca = new CellArea();
ca.startRow = 0;
ca.endRow = 2;
ca.startColumn = 0;
ca.endColumn = 0;
fcs.addArea(ca);

//Adds condition.
var idx = fcs.addCondition(FormatConditionType.DataBar);
fcs.addArea(ca);
var cond = fcs.get(idx);

//Get Databar
var dataBar = cond.dataBar;
var orange = Color.Orange;
dataBar.color = orange;

//Set Databar properties
dataBar.minCfvo.type = FormatConditionValueType.Percentile;
dataBar.minCfvo.value = 30;
dataBar.showValue = false;

//Put Cell Values
var cell1 = sheet.cells.get("A1");
cell1.putValue(10);
var cell2 = sheet.cells.get("A2");
cell2.putValue(120);
var cell3 = sheet.cells.get("A3");
cell3.putValue(260);

//Saving the Excel file
workbook.save("output/DataBar.xlsx");

Properties

PropertyTypeDescription
axisColorColorGets the color of the axis for cells with conditional formatting as data bars.
axisPositionDataBarAxisPositionGets or sets the position of the axis of the data bars specified by a conditional formatting rule.
barFillTypeDataBarFillTypeGets or sets how a data bar is filled with color.
directionTextDirectionTypeGets or sets the direction the databar is displayed.
barBorderDataBarBorderReadonly. Gets an object that specifies the border of a data bar.
negativeBarFormatNegativeBarFormatReadonly. Gets the NegativeBarFormat object associated with a data bar conditional formatting rule.
minCfvoConditionalFormattingValueReadonly. Get or set this DataBar’s min value object. Cannot set null or CFValueObject with type FormatConditionValueType.Max to it.
maxCfvoConditionalFormattingValueReadonly. Get or set this DataBar’s max value object. Cannot set null or CFValueObject with type FormatConditionValueType.Min to it.
colorColorGet or set this DataBar’s Color.
minLengthnumberRepresents the min length of data bar .
maxLengthnumberRepresents the max length of data bar .
showValuebooleanGet or set the flag indicating whether to show the values of the cells on which this data bar is applied. Default value is true.

Methods

MethodDescription
getAxisColor()@deprecated. Please use the ‘axisColor’ property instead. Gets the color of the axis for cells with conditional formatting as data bars.
setAxisColor(Color)@deprecated. Please use the ‘axisColor’ property instead. Gets the color of the axis for cells with conditional formatting as data bars.
getAxisPosition()@deprecated. Please use the ‘axisPosition’ property instead. Gets or sets the position of the axis of the data bars specified by a conditional formatting rule.
setAxisPosition(DataBarAxisPosition)@deprecated. Please use the ‘axisPosition’ property instead. Gets or sets the position of the axis of the data bars specified by a conditional formatting rule.
getBarFillType()@deprecated. Please use the ‘barFillType’ property instead. Gets or sets how a data bar is filled with color.
setBarFillType(DataBarFillType)@deprecated. Please use the ‘barFillType’ property instead. Gets or sets how a data bar is filled with color.
getDirection()@deprecated. Please use the ‘direction’ property instead. Gets or sets the direction the databar is displayed.
setDirection(TextDirectionType)@deprecated. Please use the ‘direction’ property instead. Gets or sets the direction the databar is displayed.
getBarBorder()@deprecated. Please use the ‘barBorder’ property instead. Gets an object that specifies the border of a data bar.
getNegativeBarFormat()@deprecated. Please use the ’negativeBarFormat’ property instead. Gets the NegativeBarFormat object associated with a data bar conditional formatting rule.
getMinCfvo()@deprecated. Please use the ‘minCfvo’ property instead. Get or set this DataBar’s min value object. Cannot set null or CFValueObject with type FormatConditionValueType.Max to it.
getMaxCfvo()@deprecated. Please use the ‘maxCfvo’ property instead. Get or set this DataBar’s max value object. Cannot set null or CFValueObject with type FormatConditionValueType.Min to it.
getColor()@deprecated. Please use the ‘color’ property instead. Get or set this DataBar’s Color.
setColor(Color)@deprecated. Please use the ‘color’ property instead. Get or set this DataBar’s Color.
getMinLength()@deprecated. Please use the ‘minLength’ property instead. Represents the min length of data bar .
setMinLength(number)@deprecated. Please use the ‘minLength’ property instead. Represents the min length of data bar .
getMaxLength()@deprecated. Please use the ‘maxLength’ property instead. Represents the max length of data bar .
setMaxLength(number)@deprecated. Please use the ‘maxLength’ property instead. Represents the max length of data bar .
getShowValue()@deprecated. Please use the ‘showValue’ property instead. 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.
setShowValue(boolean)@deprecated. Please use the ‘showValue’ property instead. 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.
toImage(Cell, ImageOrPrintOptions)Render data bar in cell to image byte array.
isNull()Checks whether the implementation object is null.

axisColor

Gets the color of the axis for cells with conditional formatting as data bars.

axisColor : Color;

axisPosition

Gets or sets the position of the axis of the data bars specified by a conditional formatting rule.

axisPosition : DataBarAxisPosition;

barFillType

Gets or sets how a data bar is filled with color.

barFillType : DataBarFillType;

direction

Gets or sets the direction the databar is displayed.

direction : TextDirectionType;

barBorder

Readonly. Gets an object that specifies the border of a data bar.

barBorder : DataBarBorder;

negativeBarFormat

Readonly. Gets the NegativeBarFormat object associated with a data bar conditional formatting rule.

negativeBarFormat : NegativeBarFormat;

minCfvo

Readonly. Get or set this DataBar’s min value object. Cannot set null or CFValueObject with type FormatConditionValueType.Max to it.

minCfvo : ConditionalFormattingValue;

maxCfvo

Readonly. Get or set this DataBar’s max value object. Cannot set null or CFValueObject with type FormatConditionValueType.Min to it.

maxCfvo : ConditionalFormattingValue;

color

Get or set this DataBar’s Color.

color : Color;

minLength

Represents the min length of data bar .

minLength : number;

maxLength

Represents the max length of data bar .

maxLength : number;

showValue

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.

showValue : boolean;

getAxisColor()

@deprecated. Please use the ‘axisColor’ property instead. Gets the color of the axis for cells with conditional formatting as data bars.

getAxisColor() : Color;

Returns

Color

setAxisColor(Color)

@deprecated. Please use the ‘axisColor’ property instead. Gets the color of the axis for cells with conditional formatting as data bars.

setAxisColor(value: Color) : void;

Parameters:

ParameterTypeDescription
valueColorThe value to set.

getAxisPosition()

@deprecated. Please use the ‘axisPosition’ property instead. Gets or sets the position of the axis of the data bars specified by a conditional formatting rule.

getAxisPosition() : DataBarAxisPosition;

Returns

DataBarAxisPosition

setAxisPosition(DataBarAxisPosition)

@deprecated. Please use the ‘axisPosition’ property instead. Gets or sets the position of the axis of the data bars specified by a conditional formatting rule.

setAxisPosition(value: DataBarAxisPosition) : void;

Parameters:

ParameterTypeDescription
valueDataBarAxisPositionThe value to set.

getBarFillType()

@deprecated. Please use the ‘barFillType’ property instead. Gets or sets how a data bar is filled with color.

getBarFillType() : DataBarFillType;

Returns

DataBarFillType

setBarFillType(DataBarFillType)

@deprecated. Please use the ‘barFillType’ property instead. Gets or sets how a data bar is filled with color.

setBarFillType(value: DataBarFillType) : void;

Parameters:

ParameterTypeDescription
valueDataBarFillTypeThe value to set.

getDirection()

@deprecated. Please use the ‘direction’ property instead. Gets or sets the direction the databar is displayed.

getDirection() : TextDirectionType;

Returns

TextDirectionType

setDirection(TextDirectionType)

@deprecated. Please use the ‘direction’ property instead. Gets or sets the direction the databar is displayed.

setDirection(value: TextDirectionType) : void;

Parameters:

ParameterTypeDescription
valueTextDirectionTypeThe value to set.

getBarBorder()

@deprecated. Please use the ‘barBorder’ property instead. Gets an object that specifies the border of a data bar.

getBarBorder() : DataBarBorder;

Returns

DataBarBorder

getNegativeBarFormat()

@deprecated. Please use the ’negativeBarFormat’ property instead. Gets the NegativeBarFormat object associated with a data bar conditional formatting rule.

getNegativeBarFormat() : NegativeBarFormat;

Returns

NegativeBarFormat

getMinCfvo()

@deprecated. Please use the ‘minCfvo’ property instead. Get or set this DataBar’s min value object. Cannot set null or CFValueObject with type FormatConditionValueType.Max to it.

getMinCfvo() : ConditionalFormattingValue;

Returns

ConditionalFormattingValue

getMaxCfvo()

@deprecated. Please use the ‘maxCfvo’ property instead. Get or set this DataBar’s max value object. Cannot set null or CFValueObject with type FormatConditionValueType.Min to it.

getMaxCfvo() : ConditionalFormattingValue;

Returns

ConditionalFormattingValue

getColor()

@deprecated. Please use the ‘color’ property instead. Get or set this DataBar’s Color.

getColor() : Color;

Returns

Color

setColor(Color)

@deprecated. Please use the ‘color’ property instead. Get or set this DataBar’s Color.

setColor(value: Color) : void;

Parameters:

ParameterTypeDescription
valueColorThe value to set.

getMinLength()

@deprecated. Please use the ‘minLength’ property instead. Represents the min length of data bar .

getMinLength() : number;

setMinLength(number)

@deprecated. Please use the ‘minLength’ property instead. Represents the min length of data bar .

setMinLength(value: number) : void;

Parameters:

ParameterTypeDescription
valuenumberThe value to set.

getMaxLength()

@deprecated. Please use the ‘maxLength’ property instead. Represents the max length of data bar .

getMaxLength() : number;

setMaxLength(number)

@deprecated. Please use the ‘maxLength’ property instead. Represents the max length of data bar .

setMaxLength(value: number) : void;

Parameters:

ParameterTypeDescription
valuenumberThe value to set.

getShowValue()

@deprecated. Please use the ‘showValue’ property instead. 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.

getShowValue() : boolean;

setShowValue(boolean)

@deprecated. Please use the ‘showValue’ property instead. 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.

setShowValue(value: boolean) : void;

Parameters:

ParameterTypeDescription
valuebooleanThe value to set.

toImage(Cell, ImageOrPrintOptions)

Render data bar in cell to image byte array.

toImage(cell: Cell, imgOpts: ImageOrPrintOptions) : Uint8Array;

Parameters:

ParameterTypeDescription
cellCellIndicate the data bar in which cell to be rendered
imgOptsImageOrPrintOptionsImageOrPrintOptions contains some property of output image

isNull()

Checks whether the implementation object is null.

isNull() : boolean;