DataSorter Class

Summary description for DataSorter.
Inheritance Hierarchy
SystemObject
  Aspose.CellsDataSorter

Namespace:  Aspose.Cells
Assembly:  Aspose.Cells (in Aspose.Cells.dll) Version: 20.10.0.0 (20.10)
Syntax
public class DataSorter

The DataSorter type exposes the following members.

Properties
  NameDescription
Public propertyCaseSensitive
Gets and sets whether case sensitive when comparing string.
Public propertyHasHeaders
Represents whether the range has headers.
Public propertyKey1
Represents first sorted column index(absolute position, column A is 0, B is 1, ...).
Public propertyKey2
Represents second sorted column index(absolute position, column A is 0, B is 1, ...).
Public propertyKey3
Represents third sorted column index(absolute position, column A is 0, B is 1, ...).
Public propertyKeys
Gets the key list of data sorter.
Public propertyOrder1
Represents sort order of the first key.
Public propertyOrder2
Represents sort order of the second key.
Public propertyOrder3
Represents sort order of the third key.
Public propertySortAsNumber
Indicates whether sorting anything that looks like a number.
Public propertySortLeftToRight
True means that sorting orientation is from left to right. False means that sorting orientation is from top to bottom. The default value is false.
Methods
  NameDescription
Public methodAddKey(Int32, SortOrder)
Adds sorted column index and sort order.
Public methodAddKey(Int32, SortOrder, String)
Adds sorted column index and sort order with custom sort list.
Public methodAddKey(Int32, SortOrder, String)
Adds sorted column index and sort order with custom sort list.
Public methodAddKey(Int32, SortOnType, SortOrder, Object)
Adds sorted column index and sort order with custom sort list.
Public methodClear
Clear all settings.
Public methodEquals (Inherited from Object.)
Protected methodFinalize (Inherited from Object.)
Public methodGetHashCode (Inherited from Object.)
Public methodGetType (Inherited from Object.)
Protected methodMemberwiseClone (Inherited from Object.)
Public methodSort
Sort the data in the range.
Public methodSort(Cells, CellArea)
Sort the data of the area.
Public methodSort(Cells, Int32, Int32, Int32, Int32)
Sorts the data of the area.
Public methodToString (Inherited from Object.)
Examples
[C#]

//Instantiate a new Workbook object.
Workbook workbook = new Workbook("C:\\Book1.xls");
//Get the workbook datasorter object.
DataSorter sorter = workbook.DataSorter;
//Set the first order for datasorter object.
sorter.Order1 = Aspose.Cells.SortOrder.Descending;
//Define the first key.
sorter.Key1 = 0;
//Set the second order for datasorter object.
sorter.Order2 = Aspose.Cells.SortOrder.Ascending;
//Define the second key.
sorter.Key2 = 1;
//Create a cells area (range).
CellArea ca = new CellArea();
//Specify the start row index.
ca.StartRow = 0;
//Specify the start column index.
ca.StartColumn = 0;
//Specify the last row index.
ca.EndRow = 13;
//Specify the last column index.
ca.EndColumn = 1;
//Sort data in the specified data range (A1:B14)
sorter.Sort(workbook.Worksheets[0].Cells, ca);
//Save the excel file.
workbook.Save("C:\\outBook.xls");

[Visual Basic]

'Instantiate a new Workbook object.
Dim workbook As Workbook = New Workbook("C:\Book1.xls")
'Get the workbook datasorter object.
Dim sorter As DataSorter = workbook.DataSorter
'Set the first order for datasorter object
sorter.Order1 = Aspose.Cells.SortOrder.Descending
'Define the first key.
sorter.Key1 = 0
'Set the second order for datasorter object.
sorter.Order2 = Aspose.Cells.SortOrder.Ascending
'Define the second key.
sorter.Key2 = 1
'Create a cells area (range).
Dim ca As CellArea = New CellArea
'Specify the start row index.
ca.StartRow = 0
'Specify the start column index.
ca.StartColumn = 0
'Specify the last row index.
ca.EndRow = 13
'Specify the last column index.
ca.EndColumn = 1
'Sort the data in the specified data range (A1:B14)
sorter.Sort(workbook.Worksheets(0).Cells, ca)
'Save the excel file.
workbook.Save("C:\outBook.xls")
See Also