[]
Sorts the cells represented by this range according to the specified options.
void Sort(SortOrientation orientation = SortOrientation.Columns, bool caseSensitive = false, params IValueSortField[] keys)
Sub Sort(Optional orientation As SortOrientation = SortOrientation.Columns, Optional caseSensitive As Boolean = False, ParamArray keys As IValueSortField())
| Type | Name | Description |
|---|---|---|
| SortOrientation | orientation | The orientation. |
| bool | caseSensitive | if set to |
| IValueSortField[] | keys | The SortFieldBase array. |
worksheet.Range["A1:B4"].Value = new object[,] {
{"Name", "Score"},
{"Alice", 95},
{"Bob", 70},
{"Carol", 88}
});
ValueSortField key = new ValueSortField(worksheet.Range["B2:B4"]);
worksheet.Range["A2:B4"].Sort(SortOrientation.Columns, false, key);
object firstScore = worksheet.Range["B2"].Value;
Sorts the cells represented by this range according to the specified options.
void Sort(IRange key, SortOrder order = SortOrder.Ascending, SortOrientation orientation = SortOrientation.Columns, bool caseSensitive = false)
Sub Sort(key As IRange, Optional order As SortOrder = SortOrder.Ascending, Optional orientation As SortOrientation = SortOrientation.Columns, Optional caseSensitive As Boolean = False)
| Type | Name | Description |
|---|---|---|
| IRange | key | The key of the sort column. |
| SortOrder | order | The sort order, ascending or descending |
| SortOrientation | orientation | The orientation. |
| bool | caseSensitive | if set to |
worksheet.Range["A1:B4"].Value = new object[,] {
{"Name", "Score"},
{"Alice", 95},
{"Bob", 70},
{"Carol", 88}
});
worksheet.Range["A2:B4"].Sort(worksheet.Range["B2:B4"], SortOrder.Ascending, SortOrientation.Columns);
object firstScore = worksheet.Range["B2"].Value;