Class DataBar
Namespace: Aspose.Cells
Assembly: Aspose.Cells.dll (25.2.0)
Mô tả quy tắc định dạng có điều kiện DataBar.
Quy tắc định dạng có điều kiện này hiển thị một thanh dữ liệu có độ dốc trong phạm vi các ô.
public class DataBar
Kế thừa
Các thành viên được kế thừa
object.GetType(), object.MemberwiseClone(), object.ToString(), object.Equals(object?), object.Equals(object?, object?), object.ReferenceEquals(object?, object?), object.GetHashCode()
Ví dụ
//Khởi tạo một đối tượng Workbook
Workbook workbook = new Workbook();
Worksheet sheet = workbook.Worksheets[0];
//Thêm một định dạng có điều kiện trống
int index = sheet.ConditionalFormattings.Add();
FormatConditionCollection fcs = sheet.ConditionalFormattings[index];
//Đặt phạm vi định dạng có điều kiện.
CellArea ca = new CellArea();
ca.StartRow = 0;
ca.EndRow = 2;
ca.StartColumn = 0;
ca.EndColumn = 0;
fcs.AddArea(ca);
//Thêm điều kiện.
int idx = fcs.AddCondition(FormatConditionType.DataBar);
fcs.AddArea(ca);
FormatCondition cond = fcs[idx];
//Lấy Databar
DataBar dataBar = cond.DataBar;
dataBar.Color = Color.Orange;
//Đặt thuộc tính 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;
//Đặt giá trị ô
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);
//Lưu tệp Excel
workbook.Save("book1.xlsx");
'Khởi tạo một đối tượng Workbook
Dim workbook As Workbook = New Workbook()
Dim sheet As Worksheet = workbook.Worksheets(0)
'Thêm một định dạng có điều kiện trống
Dim index As Integer = sheet.ConditionalFormattings.Add()
Dim fcs As FormatConditionCollection = sheet.ConditionalFormattings(index)
'Đặt phạm vi định dạng có điều kiện.
Dim ca As New CellArea()
ca.StartRow = 0
ca.EndRow = 2
ca.StartColumn = 0
ca.EndColumn = 0
fcs.AddArea(ca)
'Thêm điều kiện.
Dim idx As Integer = fcs.AddCondition(FormatConditionType.DataBar)
fcs.AddArea(ca)
Dim cond As FormatCondition = fcs(idx)
'Lấy Databar
Dim dataBar As DataBar = cond.DataBar
dataBar.Color = Color.Orange
'Đặt thuộc tính 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
'Đặt giá trị ô
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)
'Lưu tệp Excel
workbook.Save("book1.xlsx")
Thuộc tính
AxisColor
Lấy màu của trục cho các ô có định dạng có điều kiện dưới dạng thanh dữ liệu.
public Color AxisColor { get; set; }
Giá trị thuộc tính
AxisPosition
Lấy hoặc đặt vị trí của trục của các thanh dữ liệu được chỉ định bởi quy tắc định dạng có điều kiện.
public DataBarAxisPosition AxisPosition { get; set; }
Giá trị thuộc tính
BarBorder
Lấy một đối tượng xác định đường viền của một thanh dữ liệu.
public DataBarBorder BarBorder { get; }
Giá trị thuộc tính
BarFillType
Lấy hoặc đặt cách mà một thanh dữ liệu được tô màu.
public DataBarFillType BarFillType { get; set; }
Giá trị thuộc tính
Color
Lấy hoặc đặt màu của DataBar này.
public Color Color { get; set; }
Giá trị thuộc tính
Direction
Lấy hoặc đặt hướng mà thanh dữ liệu được hiển thị.
public TextDirectionType Direction { get; set; }
Giá trị thuộc tính
MaxCfvo
Lấy hoặc đặt đối tượng giá trị tối đa của DataBar này.
Không thể đặt null hoặc CFValueObject với loại FormatConditionValueType.Min cho nó.
public ConditionalFormattingValue MaxCfvo { get; }
Giá trị thuộc tính
MaxLength
Đại diện cho độ dài tối đa của thanh dữ liệu.
public int MaxLength { get; set; }
Giá trị thuộc tính
MinCfvo
Lấy hoặc đặt đối tượng giá trị tối thiểu của DataBar này.
Không thể đặt null hoặc CFValueObject với loại FormatConditionValueType.Max cho nó.
public ConditionalFormattingValue MinCfvo { get; }
Giá trị thuộc tính
MinLength
Đại diện cho độ dài tối thiểu của thanh dữ liệu.
public int MinLength { get; set; }
Giá trị thuộc tính
NegativeBarFormat
Lấy đối tượng NegativeBarFormat liên kết với quy tắc định dạng có điều kiện của thanh dữ liệu.
public NegativeBarFormat NegativeBarFormat { get; }
Giá trị thuộc tính
ShowValue
Lấy hoặc đặt cờ chỉ định xem có hiển thị giá trị của các ô mà thanh dữ liệu này được áp dụng hay không.
Giá trị mặc định là true.
public bool ShowValue { get; set; }
Giá trị thuộc tính
Phương thức
ToImage(Cell, ImageOrPrintOptions)
Chuyển đổi thanh dữ liệu trong ô thành mảng byte hình ảnh.
public byte[] ToImage(Cell cell, ImageOrPrintOptions imgOpts)
Tham số
cell
Cell
Chỉ định thanh dữ liệu trong ô nào sẽ được chuyển đổi
imgOpts
ImageOrPrintOptions
ImageOrPrintOptions chứa một số thuộc tính của hình ảnh đầu ra
Trả về
byte[]