Class SortBuilder
Fluent builder for multi-level sort operations on a Range.
Created by the SortingExtensions.Sort extension method and
Sort(Range).
Inherited Members
Namespace: DRIT.Spreadsheet
Assembly: DRIT.Spreadsheet.dll
Syntax
public class SortBuilder
Remarks
Each call to By(int, bool) adds a sort level. Call Apply() to execute the sort.
worksheet.GetRange("A1:C10")
.Sort(ascending: true)
.By(1, descending: true)
.Apply();
Properties
SortState
Gets the underlying SortState that will be applied.
Declaration
public SortState SortState { get; }
Property Value
| Type | Description |
|---|---|
| SortState |
Remarks
Each call to By(int, bool) adds a sort level. Call Apply() to execute the sort.
worksheet.GetRange("A1:C10")
.Sort(ascending: true)
.By(1, descending: true)
.Apply();
Methods
Apply()
Executes the sort described by this builder.
Declaration
public void Apply()
Remarks
Each call to By(int, bool) adds a sort level. Call Apply() to execute the sort.
worksheet.GetRange("A1:C10")
.Sort(ascending: true)
.By(1, descending: true)
.Apply();
By(int, bool)
Adds a sort level for the specified column index.
Declaration
public SortBuilder By(int columnIndex, bool descending = false)
Parameters
| Type | Name | Description |
|---|---|---|
| int | columnIndex | Zero-based index of the column within the sort range. |
| bool | descending | When true sort this level descending; otherwise ascending. |
Returns
| Type | Description |
|---|---|
| SortBuilder |
Remarks
Each call to By(int, bool) adds a sort level. Call Apply() to execute the sort.
worksheet.GetRange("A1:C10")
.Sort(ascending: true)
.By(1, descending: true)
.Apply();