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.getWorksheets().get(0);

//Adds an empty conditional formatting
var index = sheet.getConditionalFormattings().add();
var fcs = sheet.getConditionalFormattings().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.getDataBar();
var orange = Color.Orange;
dataBar.setColor(orange);

//Set Databar properties
dataBar.getMinCfvo().setType(FormatConditionValueType.Percentile);
dataBar.getMinCfvo().setValue(30);
dataBar.setShowValue(false);

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

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

Methods

MethodDescription
getAxisColor()Gets the color of the axis for cells with conditional formatting as data bars.
setAxisColor(Color)Gets the color of the axis for cells with conditional formatting as data bars.
getAxisPosition()Gets or sets the position of the axis of the data bars specified by a conditional formatting rule.
setAxisPosition(DataBarAxisPosition)Gets or sets the position of the axis of the data bars specified by a conditional formatting rule.
getBarFillType()Gets or sets how a data bar is filled with color.
setBarFillType(DataBarFillType)Gets or sets how a data bar is filled with color.
getDirection()Gets or sets the direction the databar is displayed.
setDirection(TextDirectionType)Gets or sets the direction the databar is displayed.
getBarBorder()Gets an object that specifies the border of a data bar.
getNegativeBarFormat()Gets the NegativeBarFormat object associated with a data bar conditional formatting rule.
getMinCfvo()Get or set this DataBar’s min value object. Cannot set null or CFValueObject with type FormatConditionValueType.Max to it.
getMaxCfvo()Get or set this DataBar’s max value object. Cannot set null or CFValueObject with type FormatConditionValueType.Min to it.
getColor()Get or set this DataBar’s Color.
setColor(Color)Get or set this DataBar’s Color.
getMinLength()Represents the min length of data bar .
setMinLength(number)Represents the min length of data bar .
getMaxLength()Represents the max length of data bar .
setMaxLength(number)Represents the max length of data bar .
getShowValue()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)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.

getAxisColor()

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

getAxisColor() : Color;

Returns

Color

setAxisColor(Color)

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()

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

getAxisPosition() : DataBarAxisPosition;

Returns

DataBarAxisPosition

setAxisPosition(DataBarAxisPosition)

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()

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

getBarFillType() : DataBarFillType;

Returns

DataBarFillType

setBarFillType(DataBarFillType)

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

setBarFillType(value: DataBarFillType) : void;

Parameters:

ParameterTypeDescription
valueDataBarFillTypeThe value to set.

getDirection()

Gets or sets the direction the databar is displayed.

getDirection() : TextDirectionType;

Returns

TextDirectionType

setDirection(TextDirectionType)

Gets or sets the direction the databar is displayed.

setDirection(value: TextDirectionType) : void;

Parameters:

ParameterTypeDescription
valueTextDirectionTypeThe value to set.

getBarBorder()

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

getBarBorder() : DataBarBorder;

Returns

DataBarBorder

getNegativeBarFormat()

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

getNegativeBarFormat() : NegativeBarFormat;

Returns

NegativeBarFormat

getMinCfvo()

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()

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()

Get or set this DataBar’s Color.

getColor() : Color;

Returns

Color

setColor(Color)

Get or set this DataBar’s Color.

setColor(value: Color) : void;

Parameters:

ParameterTypeDescription
valueColorThe value to set.

getMinLength()

Represents the min length of data bar .

getMinLength() : number;

setMinLength(number)

Represents the min length of data bar .

setMinLength(value: number) : void;

Parameters:

ParameterTypeDescription
valuenumberThe value to set.

getMaxLength()

Represents the max length of data bar .

getMaxLength() : number;

setMaxLength(number)

Represents the max length of data bar .

setMaxLength(value: number) : void;

Parameters:

ParameterTypeDescription
valuenumberThe value to set.

getShowValue()

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)

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) : number[];

Parameters:

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

Returns

number[]

isNull()

Checks whether the implementation object is null.

isNull() : boolean;