SortLevel Class |
Namespace: GemBox.Spreadsheet
The SortLevel type exposes the following members.
Name | Description | |
---|---|---|
![]() | ColumnRowIndex | Gets or sets the column (or the row, if LeftToRight is ) index relative to the Range that this sort level applies to. Value is equal to or greater than zero and less than Width (or Height, if LeftToRight is ) of the Range. |
![]() | Comparison | Gets or sets the comparison method that compares two ExcelCells. Default value is default comparison method based on the settings of this sort level. |
![]() | CustomList | Gets the custom list by which order of items to sort by. If Descending is set to , then sorting will be performed based on the reverse order of items. |
![]() | Descending | Gets or sets a value indicating whether to sort the values in the descending order. Default value is . |
Name | Description | |
---|---|---|
![]() | SetCustomList(IEnumerableString) | Sets the custom list by which order of items to sort by. |
![]() | SetCustomList(String) | Sets the custom list by which order of items to sort by. |
![]() | ToString |
Returns a String that represents this SortLevel instance.
(Overrides ObjectToString.) |
Following methods shows various ways to specify and apply a SortState to a range of cells.
static void Sort1(ExcelWorksheet worksheet) { // Specify and apply Sort using less-verbose, fluent, but less understandable interface. worksheet.Cells.GetSubrange("A1", "D20").Sort(true). By(0). By(1, true). By(2, "Female", "Male"). Apply(); } static void Sort2(ExcelWorksheet worksheet) { // Specify and apply Sort using more verbose, but more understandable interface. var sort = worksheet.Cells.GetSubrange("A1", "D20").Sort(true); sort.Levels.Add(0); var level2 = sort.Levels.Add(1); level2.Descending = true; var level3 = sort.Levels.Add(2); level3.SetCustomList("Female", "Male"); sort.Apply(); } static void Sort3(ExcelWorksheet worksheet) { // Specify and apply Filter using less-verbose, fluent and understandable interface (with help of C# 4.0 named arguments). worksheet.Cells.GetSubrange("A1", "D20").Sort(active: true). By(columnRowIndex: 0). By(columnRowIndex: 1, descending: true). By(columnRowIndex: 2, customList: new string[] { "Female", "Male" }). Apply(); }