Class DataBar
Namespace: Aspose.Cells
Assembly: Aspose.Cells.dll (25.2.0)
描述 DataBar 条件格式规则。
此条件格式规则在单元格范围内显示渐变数据条。
public class DataBar
继承
继承成员
object.GetType(), object.MemberwiseClone(), object.ToString(), object.Equals(object?), object.Equals(object?, object?), object.ReferenceEquals(object?, object?), object.GetHashCode()
示例
//实例化一个 Workbook 对象
Workbook workbook = new Workbook();
Worksheet sheet = workbook.Worksheets[0];
//添加一个空的条件格式
int index = sheet.ConditionalFormattings.Add();
FormatConditionCollection fcs = sheet.ConditionalFormattings[index];
//设置条件格式范围。
CellArea ca = new CellArea();
ca.StartRow = 0;
ca.EndRow = 2;
ca.StartColumn = 0;
ca.EndColumn = 0;
fcs.AddArea(ca);
//添加条件。
int idx = fcs.AddCondition(FormatConditionType.DataBar);
fcs.AddArea(ca);
FormatCondition cond = fcs[idx];
//获取 Databar
DataBar dataBar = cond.DataBar;
dataBar.Color = Color.Orange;
//设置 Databar 属性
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;
//放置单元格值
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);
//保存 Excel 文件
workbook.Save("book1.xlsx");
'实例化一个 Workbook 对象
Dim workbook As Workbook = New Workbook()
Dim sheet As Worksheet = workbook.Worksheets(0)
'添加一个空的条件格式
Dim index As Integer = sheet.ConditionalFormattings.Add()
Dim fcs As FormatConditionCollection = sheet.ConditionalFormattings(index)
'设置条件格式范围。
Dim ca As New CellArea()
ca.StartRow = 0
ca.EndRow = 2
ca.StartColumn = 0
ca.EndColumn = 0
fcs.AddArea(ca)
'添加条件。
Dim idx As Integer = fcs.AddCondition(FormatConditionType.DataBar)
fcs.AddArea(ca)
Dim cond As FormatCondition = fcs(idx)
'获取 Databar
Dim dataBar As DataBar = cond.DataBar
dataBar.Color = Color.Orange
'设置 Databar 属性
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
'放置单元格值
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)
'保存 Excel 文件
workbook.Save("book1.xlsx")
属性
AxisColor
获取具有条件格式为数据条的单元格的轴的颜色。
public Color AxisColor { get; set; }
属性值
AxisPosition
获取或设置条件格式规则指定的数据条的轴的位置。
public DataBarAxisPosition AxisPosition { get; set; }
属性值
BarBorder
获取一个对象,该对象指定数据条的边框。
public DataBarBorder BarBorder { get; }
属性值
BarFillType
获取或设置数据条填充颜色的方式。
public DataBarFillType BarFillType { get; set; }
属性值
Color
获取或设置此 DataBar 的颜色。
public Color Color { get; set; }
属性值
Direction
获取或设置数据条显示的方向。
public TextDirectionType Direction { get; set; }
属性值
MaxCfvo
获取或设置此 DataBar 的最大值对象。
不能将 null 或类型为 FormatConditionValueType.Min 的 CFValueObject 设置给它。
public ConditionalFormattingValue MaxCfvo { get; }
属性值
MaxLength
表示数据条的最大长度。
public int MaxLength { get; set; }
属性值
MinCfvo
获取或设置此 DataBar 的最小值对象。
不能将 null 或类型为 FormatConditionValueType.Max 的 CFValueObject 设置给它。
public ConditionalFormattingValue MinCfvo { get; }
属性值
MinLength
表示数据条的最小长度。
public int MinLength { get; set; }
属性值
NegativeBarFormat
获取与数据条条件格式规则关联的 NegativeBarFormat 对象。
public NegativeBarFormat NegativeBarFormat { get; }
属性值
ShowValue
获取或设置一个标志,指示是否显示应用此数据条的单元格的值。
默认值为 true。
public bool ShowValue { get; set; }
属性值
方法
ToImage(Cell, ImageOrPrintOptions)
将单元格中的数据条渲染为图像字节数组。
public byte[] ToImage(Cell cell, ImageOrPrintOptions imgOpts)
参数
cell
Cell
指示要渲染的数据条所在的单元格
imgOpts
ImageOrPrintOptions
ImageOrPrintOptions 包含输出图像的一些属性
返回
byte[]