[]
Represents sort settings.
Provides access to sort settings for a worksheet or table, including the target range, case-sensitivity, orientation, header handling, and the list of sort fields to apply. Use Range to define the cells to sort, configure fields through SortFields, and then call Apply() to perform the sort.
public interface ISort
Public Interface ISort
worksheet.Range["A1:B4"].Value = new object[,] {
{"Name", "Score"},
{"Tom", 80},
{"alice", 95},
{"Bob", 90}
};
ISort sort = worksheet.Sort;
sort.SortFields.Add(new ValueSortField(worksheet.Range["A2:A4"], SortOrder.Ascending));
sort.Range = worksheet.Range["A1:B4"];
sort.Header = true;
sort.MatchCase = true;
sort.Apply();
| Name | Description |
|---|---|
| Header | Gets or sets whether the sort range contains a header. Use this property to determine whether the current sort configuration treats the first row in the sort range as a header row. |
| MatchCase | Gets or sets whether the sort is case sensitive. This property indicates whether text values are compared by letter case when the sort is applied. |
| Orientation | Gets or sets the sort orientation. The sort orientation determines whether the sort operation is applied by columns or by rows. |
| Range | Gets or sets the range of cells to sort. |
| SortFields | Gets the ISortFields collection that defines the sort fields for this sort operation. |
| Name | Description |
|---|---|
| Apply() | Applies the configured sort settings to the current range. Call this method after setting the sort range and adding the required sort fields. If Header is true, the first row in the sort range is treated as a header row and is not moved. |