DataSorter Class
Summary description for DataSorter.
Inheritance Hierarchy
SystemObject
  Aspose.CellsDataSorter

Namespace: Aspose.Cells
Assembly: Aspose.Cells (in Aspose.Cells.dll) Version: 19.9.0.0 (19.9)
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.
Public propertyKey2
Represents second sorted column index.
Public propertyKey3
Represents third sorted column index.
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
Determines whether the specified Object is equal to the current Object.
(Inherited from Object.)
Protected methodFinalize
Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection.
(Inherited from Object.)
Public methodGetHashCode
Serves as a hash function for a particular type.
(Inherited from Object.)
Public methodGetType
Gets the type of the current instance.
(Inherited from Object.)
Protected methodMemberwiseClone
Creates a shallow copy of the current Object.
(Inherited from Object.)
Public methodSort
Sort the data in the range.
Public methodSort(Cells, CellArea)
Sort the datas of the area.
Public methodSort(Cells, Int32, Int32, Int32, Int32)
Sorts the data of the area.
Public methodToString
Returns a string that represents the current object.
(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