Class DataBar

Class DataBar

Namespace: Aspose.Cells
Assembly: Aspose.Cells.dll (25.2.0)

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

public class DataBar

Inheritance

objectDataBar

Inherited Members

object.GetType(), object.MemberwiseClone(), object.ToString(), object.Equals(object?), object.Equals(object?, object?), object.ReferenceEquals(object?, object?), object.GetHashCode()

Examples

csharp
[C#]

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

Worksheet sheet = workbook.Worksheets[0];

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

FormatConditionCollection 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.AddCondition(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.Solid;

dataBar.BarBorder.Color = Color.Plum;

 dataBar.BarFillType = DataBarFillType.Solid;

 dataBar.AxisColor = Color.Red;

 dataBar.AxisPosition = DataBarAxisPosition.Midpoint;

 dataBar.NegativeBarFormat.ColorType = DataBarNegativeColorType.Color;

 dataBar.NegativeBarFormat.Color = Color.White;

 dataBar.NegativeBarFormat.BorderColorType = DataBarNegativeColorType.Color;

 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("book1.xlsx");

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

Dim sheet As Worksheet = workbook.Worksheets(0)

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

Dim fcs As FormatConditionCollection = 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.AddCondition(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.Solid

dataBar.BarBorder.Color = Color.Plum

 dataBar.BarFillType = DataBarFillType.Solid

 dataBar.AxisColor = Color.Red

 dataBar.AxisPosition = DataBarAxisPosition.Midpoint

 dataBar.NegativeBarFormat.ColorType = DataBarNegativeColorType.Color

 dataBar.NegativeBarFormat.Color = Color.White

 dataBar.NegativeBarFormat.BorderColorType = DataBarNegativeColorType.Color

 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("book1.xlsx")

Properties

AxisColor

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

public Color AxisColor { get; set; }

Property Value

Color

AxisPosition

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

public DataBarAxisPosition AxisPosition { get; set; }

Property Value

DataBarAxisPosition

BarBorder

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

public DataBarBorder BarBorder { get; }

Property Value

DataBarBorder

BarFillType

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

public DataBarFillType BarFillType { get; set; }

Property Value

DataBarFillType

Color

Get or set this DataBar’s Color.

public Color Color { get; set; }

Property Value

Color

Direction

Gets or sets the direction the databar is displayed.

public TextDirectionType Direction { get; set; }

Property Value

TextDirectionType

MaxCfvo

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

public ConditionalFormattingValue MaxCfvo { get; }

Property Value

ConditionalFormattingValue

MaxLength

Represents the max length of data bar .

public int MaxLength { get; set; }

Property Value

int

MinCfvo

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

public ConditionalFormattingValue MinCfvo { get; }

Property Value

ConditionalFormattingValue

MinLength

Represents the min length of data bar .

public int MinLength { get; set; }

Property Value

int

NegativeBarFormat

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

public NegativeBarFormat NegativeBarFormat { get; }

Property Value

NegativeBarFormat

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.

public bool ShowValue { get; set; }

Property Value

bool

Methods

ToImage(Cell, ImageOrPrintOptions)

Render data bar in cell to image byte array.

public byte[] ToImage(Cell cell, ImageOrPrintOptions imgOpts)

Parameters

cell Cell

Indicate the data bar in which cell to be rendered

imgOpts ImageOrPrintOptions

ImageOrPrintOptions contains some property of output image

Returns

byte[]