officefileapi-devexpress-dot-spreadsheet-dot-worksheet-dot-sort-x28-devexpress-dot-spreadsheet-dot-cellrange-devexpress-dot-spreadsheet-dot-fill-system-dot-boolean-x29.md
Sorts the specified range by the specified color in the specified order.
Namespace : DevExpress.Spreadsheet
Assembly : DevExpress.Spreadsheet.v25.2.Core.dll
NuGet Package : DevExpress.Spreadsheet.Core
void Sort(
CellRange range,
Fill fill,
bool ascending
)
Sub Sort(
range As CellRange,
fill As Fill,
ascending As Boolean
)
| Name | Type | Description |
|---|---|---|
| range | CellRange |
The range of worksheet cells.
| | fill | Fill |
An object that contains the fill parameters.
| | ascending | Boolean |
true to specify ascending order; otherwise, false.
|
The following code sample sorts the cell range by background color in descending order:
using DevExpress.Spreadsheet;
using System.Diagnostics;
using (var workbook = new Workbook()) {
workbook.LoadDocument("Document.xlsx");
Worksheet worksheet = workbook.Worksheets["SortSample"];
workbook.Worksheets.ActiveWorksheet = worksheet;
CellRange range = worksheet.Range["A3:F22"];
Fill fillSettings = worksheet["A3"].Fill;
worksheet.Sort(range, fillSettings, false);
workbook.SaveDocument("result.xlsx", DocumentFormat.Xlsx);
Process.Start(new ProcessStartInfo("result.xlsx") { UseShellExecute = true });
}
Imports DevExpress.Spreadsheet
Imports System.Diagnostics
Using workbook = New Workbook()
workbook.LoadDocument("Document.xlsx")
Dim worksheet As Worksheet = workbook.Worksheets("SortSample")
workbook.Worksheets.ActiveWorksheet = worksheet
Dim range As CellRange = worksheet.Range("A3:F22")
Dim fillSettings As Fill = worksheet("A3").Fill
worksheet.Sort(range, fillSettings, false)
workbook.SaveDocument("result.xlsx", DocumentFormat.Xlsx)
Process.Start(New ProcessStartInfo("result.xlsx") With {.UseShellExecute = True})
End Using
See Also