DataBar Class
Describe the DataBar conditional formatting rule. This conditional formatting rule displays a gradated data bar in the range of cells.
Inheritance Hierarchy
SystemObject
  Aspose.CellsDataBar

Namespace: Aspose.Cells
Assembly: Aspose.Cells (in Aspose.Cells.dll) Version: 19.11.0.0 (19.11)
Syntax
public class DataBar

The DataBar type exposes the following members.

Properties
  NameDescription
Public propertyAxisColor
Gets the color of the axis for cells with conditional formatting as data bars.
Public propertyAxisPosition
Gets or sets the position of the axis of the data bars specified by a conditional formatting rule.
Public propertyBarBorder
Gets an object that specifies the border of a data bar.
Public propertyBarFillType
Gets or sets how a data bar is filled with color.
Public propertyColor
Get or set this DataBar's Color.
Public propertyDirection
Gets or sets the direction the databar is displayed.
Public propertyMaxCfvo
Get or set this DataBar's max value object. Cannot set null or CFValueObject with type FormatConditionValueType.Min to it.
Public propertyMaxLength
Represents the max length of data bar .
Public propertyMinCfvo
Get or set this DataBar's min value object. Cannot set null or CFValueObject with type FormatConditionValueType.Max to it.
Public propertyMinLength
Represents the min length of data bar .
Public propertyNegativeBarFormat
Gets the NegativeBarFormat object associated with a data bar conditional formatting rule.
Public propertyShowValue
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.
Methods
  NameDescription
Public methodEquals
Determines whether the specified Object is equal to the current Object.
(Inherited from Object.)
Protected methodFinalize
Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection.
(Inherited from Object.)
Public methodGetHashCode
Serves as a hash function for a particular type.
(Inherited from Object.)
Public methodGetType
Gets the type of the current instance.
(Inherited from Object.)
Protected methodMemberwiseClone
Creates a shallow copy of the current Object.
(Inherited from Object.)
Public methodToImage
Render data bar in cell to image byte array.
Public methodToString
Returns a string that represents the current object.
(Inherited from Object.)
Examples
[C#]

//Instantiating a Workbook object
Workbook workbook = new Workbook();

Worksheet sheet = workbook.Worksheets[0];

//Adds an empty conditional formatting
int index = sheet.ConditionalFormattings.Add();

FormatConditions fcs = sheet.ConditionalFormattings[index];

//Sets the conditional format range.
CellArea ca = new CellArea();

ca.StartRow = 0;

ca.EndRow = 2;

ca.StartColumn = 0;

ca.EndColumn = 0;

fcs.AddArea(ca);

//Adds condition.
int idx = fcs.AddCondtion(FormatConditionType.DataBar);

fcs.AddArea(ca);

FormatCondition cond = fcs[idx];

//Get Databar
DataBar dataBar = cond.DataBar;

dataBar.Color = Color.Orange;

//Set Databar properties
dataBar.MinCfvo.Type = FormatConditionValueType.Percentile;

dataBar.MinCfvo.Value = 30;

dataBar.ShowValue = false;

dataBar.BarBorder.Type = DataBarBorderType.DataBarBorderSolid;

dataBar.BarBorder.Color = Color.Plum;

 dataBar.BarFillType = DataBarFillType.DataBarFillSolid;

 dataBar.AxisColor = Color.Red;

 dataBar.AxisPosition = DataBarAxisPosition.DataBarAxisMidpoint;

 dataBar.NegativeBarFormat.ColorType = DataBarNegativeColorType.DataBarColor;

 dataBar.NegativeBarFormat.Color = Color.White;

 dataBar.NegativeBarFormat.BorderColorType = DataBarNegativeColorType.DataBarColor;

 dataBar.NegativeBarFormat.BorderColor = Color.Yellow;

//Put Cell Values
Aspose.Cells.Cell cell1 = sheet.Cells["A1"];

cell1.PutValue(10);

Aspose.Cells.Cell cell2 = sheet.Cells["A2"];

cell2.PutValue(120);

Aspose.Cells.Cell cell3 = sheet.Cells["A3"];

cell3.PutValue(260);

//Saving the Excel file
workbook.Save("D:\\book1.xlsx");

[VB.NET]

'Instantiating a Workbook object
Dim workbook As New Workbook()

Dim sheet As Worksheet = workbook.Worksheets(0)

'Adds an empty conditional formatting
Dim index As Integer = sheet.ConditionalFormattings.Add()

Dim fcs As FormatConditions = sheet.ConditionalFormattings(index)

'Sets the conditional format range.
Dim ca As New CellArea()

ca.StartRow = 0

ca.EndRow = 2

ca.StartColumn = 0

ca.EndColumn = 0

fcs.AddArea(ca)

'Adds condition.
Dim idx As Integer = fcs.AddCondtion(FormatConditionType.DataBar)

fcs.AddArea(ca)

Dim cond As FormatCondition = fcs(idx)

'Get Databar
Dim dataBar As DataBar = cond.DataBar

dataBar.Color = Color.Orange

'Set Databar properties
dataBar.MinCfvo.Type = FormatConditionValueType.Percentile

dataBar.MinCfvo.Value = 30

dataBar.ShowValue = False

dataBar.BarBorder.Type = DataBarBorderType.DataBarBorderSolid

dataBar.BarBorder.Color = Color.Plum

 dataBar.BarFillType = DataBarFillType.DataBarFillSolid

 dataBar.AxisColor = Color.Red

 dataBar.AxisPosition = DataBarAxisPosition.DataBarAxisMidpoint

 dataBar.NegativeBarFormat.ColorType = DataBarNegativeColorType.DataBarColor

 dataBar.NegativeBarFormat.Color = Color.White

 dataBar.NegativeBarFormat.BorderColorType = DataBarNegativeColorType.DataBarColor

 dataBar.NegativeBarFormat.BorderColor = Color.Yellow

'Put Cell Values
Dim cell1 As Aspose.Cells.Cell = sheet.Cells("A1")

cell1.PutValue(10)

Dim cell2 As Aspose.Cells.Cell = sheet.Cells("A2")

cell2.PutValue(120)

Dim cell3 As Aspose.Cells.Cell = sheet.Cells("A3")

cell3.PutValue(260)

'Saving the Excel file
workbook.Save("D:\book1.xlsx")
See Also