[]
Represents a sort field that sorts data by cell fill.
This class implements ICellColorSortField and is used to define a sort criterion based on cell fill. Add it to the worksheet's sort fields via Add(ISortField) and then apply the sort.
public class CellColorSortField : SortFieldBase, ICellColorSortField, ISortField
Public Class CellColorSortField
Inherits SortFieldBase
Implements ICellColorSortField, ISortField
worksheet.Range["A1:A3"].Value = new object[,] {{"Red"}, {"Green"}, {"Red"}};
worksheet.Range["A1"].Interior.Color = Color.Red;
worksheet.Range["A2"].Interior.Color = Color.Green;
worksheet.Range["A3"].Interior.Color = Color.Red;
CellColorSortField sortField = new CellColorSortField(
worksheet.Range["A1:A3"],
worksheet.Range["A1"].DisplayFormat.Interior,
SortOrder.Ascending);
worksheet.Sort.SortFields.Add(sortField);
worksheet.Sort.Range = worksheet.Range["A1:A3"];
worksheet.Sort.Apply();
| Name | Description |
|---|---|
| CellColorSortField(IRange, IInterior, SortOrder) | Initializes a new instance of the CellColorSortField class with the specified key range, cell fill, and sort order. |
| Name | Description |
|---|---|
| Interior | Gets the IInterior object that represents the cell fill used for sorting. |
| Order | Gets or sets the sort order. |
| SortOn | Gets the sort type. This value indicates that the sort field evaluates cells by interior color. |