Class DataSorterKeyCollection
DataSorterKeyCollection class
Represents the key list of data sorter.
public class DataSorterKeyCollection : CollectionBase<DataSorterKey>
Constructors
Properties
Methods
| Name | Description |
|---|
| BinarySearch(DataSorterKey) | |
| BinarySearch(DataSorterKey, IComparer<DataSorterKey>) | |
| BinarySearch(int, int, DataSorterKey, IComparer<DataSorterKey>) | |
| Clear() | |
| Contains(DataSorterKey) | |
| CopyTo(DataSorterKey[]) | |
| CopyTo(DataSorterKey[], int) | |
| CopyTo(int, DataSorterKey[], int, int) | |
| Exists(Predicate<DataSorterKey>) | |
| Find(Predicate<DataSorterKey>) | |
| FindAll(Predicate<DataSorterKey>) | |
| FindIndex(Predicate<DataSorterKey>) | |
| FindIndex(int, Predicate<DataSorterKey>) | |
| FindIndex(int, int, Predicate<DataSorterKey>) | |
| FindLast(Predicate<DataSorterKey>) | |
| FindLastIndex(Predicate<DataSorterKey>) | |
| FindLastIndex(int, Predicate<DataSorterKey>) | |
| FindLastIndex(int, int, Predicate<DataSorterKey>) | |
| GetEnumerator() | |
| IndexOf(DataSorterKey) | |
| IndexOf(DataSorterKey, int) | |
| IndexOf(DataSorterKey, int, int) | |
| LastIndexOf(DataSorterKey) | |
| LastIndexOf(DataSorterKey, int) | |
| LastIndexOf(DataSorterKey, int, int) | |
| RemoveAt(int) | |
Examples
namespace AsposeCellsExamples
{
using Aspose.Cells;
using System;
public class DataSorterKeyCollectionDemo
{
public static void DataSorterKeyCollectionExample()
{
// Instantiate a new Workbook object
Workbook workbook = new Workbook();
Worksheet worksheet = workbook.Worksheets[0];
// Add some sample data to the worksheet
worksheet.Cells["A1"].PutValue("Name");
worksheet.Cells["B1"].PutValue("Score");
worksheet.Cells["A2"].PutValue("John");
worksheet.Cells["B2"].PutValue(85);
worksheet.Cells["A3"].PutValue("Jane");
worksheet.Cells["B3"].PutValue(90);
worksheet.Cells["A4"].PutValue("Doe");
worksheet.Cells["B4"].PutValue(80);
// Get the workbook's DataSorter object
DataSorter sorter = workbook.DataSorter;
// Set the first order for the DataSorter object
sorter.Order1 = Aspose.Cells.SortOrder.Descending;
// Define the first key
sorter.Key1 = 1; // Sorting by the second column (Score)
// Create a cells area (range)
CellArea ca = new CellArea
{
StartRow = 1,
StartColumn = 0,
EndRow = 3,
EndColumn = 1
};
// Sort data in the specified data range (A2:B4)
sorter.Sort(worksheet.Cells, ca);
// Access the DataSorterKeyCollection
DataSorterKeyCollection keys = sorter.Keys;
// Display the count of keys
Console.WriteLine("Number of keys: " + keys.Count);
// Access the first key and display its properties
DataSorterKey key = keys[0];
Console.WriteLine("Key Index: " + key.Index);
Console.WriteLine("Key Order: " + key.Order);
// Save the workbook
workbook.Save("DataSorterKeyCollectionExample.xlsx");
workbook.Save("DataSorterKeyCollectionExample.pdf");
return;
}
}
}
See Also