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 = new Color(0xff, 0xa5, 0);
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
Method | Description |
---|---|
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
setAxisColor(Color)
Gets the color of the axis for cells with conditional formatting as data bars.
setAxisColor(value: Color) : void;
Parameters:
Parameter | Type | Description |
---|---|---|
value | Color | The 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
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:
Parameter | Type | Description |
---|---|---|
value | DataBarAxisPosition | The value to set. |
getBarFillType()
Gets or sets how a data bar is filled with color.
getBarFillType() : DataBarFillType;
Returns
setBarFillType(DataBarFillType)
Gets or sets how a data bar is filled with color.
setBarFillType(value: DataBarFillType) : void;
Parameters:
Parameter | Type | Description |
---|---|---|
value | DataBarFillType | The value to set. |
getDirection()
Gets or sets the direction the databar is displayed.
getDirection() : TextDirectionType;
Returns
setDirection(TextDirectionType)
Gets or sets the direction the databar is displayed.
setDirection(value: TextDirectionType) : void;
Parameters:
Parameter | Type | Description |
---|---|---|
value | TextDirectionType | The value to set. |
getBarBorder()
Gets an object that specifies the border of a data bar.
getBarBorder() : DataBarBorder;
Returns
getNegativeBarFormat()
Gets the NegativeBarFormat object associated with a data bar conditional formatting rule.
getNegativeBarFormat() : NegativeBarFormat;
Returns
getMinCfvo()
Get or set this DataBar’s min value object. Cannot set null or CFValueObject with type FormatConditionValueType.Max to it.
getMinCfvo() : ConditionalFormattingValue;
Returns
getMaxCfvo()
Get or set this DataBar’s max value object. Cannot set null or CFValueObject with type FormatConditionValueType.Min to it.
getMaxCfvo() : ConditionalFormattingValue;
Returns
getColor()
Get or set this DataBar’s Color.
getColor() : Color;
Returns
setColor(Color)
Get or set this DataBar’s Color.
setColor(value: Color) : void;
Parameters:
Parameter | Type | Description |
---|---|---|
value | Color | The 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:
Parameter | Type | Description |
---|---|---|
value | number | The 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:
Parameter | Type | Description |
---|---|---|
value | number | The 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:
Parameter | Type | Description |
---|---|---|
value | boolean | The value to set. |
toImage(Cell, ImageOrPrintOptions)
Render data bar in cell to image byte array.
toImage(cell: Cell, imgOpts: ImageOrPrintOptions) : number[];
Parameters:
Parameter | Type | Description |
---|---|---|
cell | Cell | Indicate the data bar in which cell to be rendered |
imgOpts | ImageOrPrintOptions | ImageOrPrintOptions contains some property of output image |
Returns
number[]
isNull()
Checks whether the implementation object is null.
isNull() : boolean;