[]
Represents a sort field that sorts data by font color.
Use this class to define a sort condition that compares the font color in a key range instead of the cell value. Add the created sort field to a worksheet sort to move rows or columns with the specified font color to the top or bottom, depending on the SortOrder.
public class FontColorSortField : SortFieldBase, IFontColorSortField, ISortField
Public Class FontColorSortField
Inherits SortFieldBase
Implements IFontColorSortField, ISortField
worksheet.Range["A1:B4"].Value = new object[,] {
{"Name", "Score"},
{"Amy", 2},
{"Ben", 1},
{"Cara", 3}
};
worksheet.Range["B3"].Font.Color = Color.Red;
FontColorSortField sortField = new FontColorSortField(worksheet.Range["B2:B4"], Color.Red, SortOrder.Ascending);
worksheet.Sort.SortFields.Add(sortField);
worksheet.Sort.Range = worksheet.Range["A2:B4"];
worksheet.Sort.Orientation = SortOrientation.Columns;
worksheet.Sort.Apply();
| Name | Description |
|---|---|
| FontColorSortField(IRange, Color, SortOrder) | Creates a sort field that sorts by font color. Use this constructor to define a sort key range, the font color to sort on, and the SortOrder that determines whether matching values are placed first or last in the sorted result. |
| Name | Description |
|---|---|
| Color | Gets the Color used to sort by. |
| Order | Gets the sort order. |
| SortOn | Gets the sort type. This value indicates that the sort field evaluates cells by font color. |