DataSorter

DataSorter class

Summary description for DataSorter.

class DataSorter;

Example

const { Workbook, CellArea, SortOrder } = require("aspose.cells.node");

//Instantiate a new Workbook object.
var workbook = new Workbook("input/DataSorter.xls");
//Get the workbook datasorter object.
var sorter = workbook.dataSorter;
//Set the first order for datasorter object.
sorter.order1 = SortOrder.Descending;
//Define the first key.
sorter.key1 = 0;
//Create a cells area (range).
var 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 = 12;
//Specify the last column index.
ca.endColumn = 1;
//Sort data in the specified data range (A1:B14)
sorter.sort(workbook.worksheets.get(0).cells, ca);
//Save the excel file.
workbook.save("output/DataSorter.xls");

Properties

PropertyTypeDescription
keysDataSorterKeyCollectionReadonly. Gets the key list of data sorter.
hasHeadersbooleanRepresents whether the range has headers.
key1numberRepresents first sorted column index(absolute position, column A is 0, B is 1, …).
order1SortOrderRepresents sort order of the first key.
key2numberRepresents second sorted column index(absolute position, column A is 0, B is 1, …).
order2SortOrderRepresents sort order of the second key.
key3numberRepresents third sorted column index(absolute position, column A is 0, B is 1, …).
order3SortOrderRepresents sort order of the third key.
sortLeftToRightbooleanTrue means that sorting orientation is from left to right. False means that sorting orientation is from top to bottom. The default value is false.
caseSensitivebooleanGets and sets whether case sensitive when comparing string.
sortAsNumberbooleanIndicates whether sorting anything that looks like a number.

Methods

MethodDescription
getKeys()@deprecated. Please use the ‘keys’ property instead. Gets the key list of data sorter.
getHasHeaders()@deprecated. Please use the ‘hasHeaders’ property instead. Represents whether the range has headers.
setHasHeaders(boolean)@deprecated. Please use the ‘hasHeaders’ property instead. Represents whether the range has headers.
getKey1()@deprecated. Please use the ‘key1’ property instead. Represents first sorted column index(absolute position, column A is 0, B is 1, …).
setKey1(number)@deprecated. Please use the ‘key1’ property instead. Represents first sorted column index(absolute position, column A is 0, B is 1, …).
getOrder1()@deprecated. Please use the ‘order1’ property instead. Represents sort order of the first key.
setOrder1(SortOrder)@deprecated. Please use the ‘order1’ property instead. Represents sort order of the first key.
getKey2()@deprecated. Please use the ‘key2’ property instead. Represents second sorted column index(absolute position, column A is 0, B is 1, …).
setKey2(number)@deprecated. Please use the ‘key2’ property instead. Represents second sorted column index(absolute position, column A is 0, B is 1, …).
getOrder2()@deprecated. Please use the ‘order2’ property instead. Represents sort order of the second key.
setOrder2(SortOrder)@deprecated. Please use the ‘order2’ property instead. Represents sort order of the second key.
getKey3()@deprecated. Please use the ‘key3’ property instead. Represents third sorted column index(absolute position, column A is 0, B is 1, …).
setKey3(number)@deprecated. Please use the ‘key3’ property instead. Represents third sorted column index(absolute position, column A is 0, B is 1, …).
getOrder3()@deprecated. Please use the ‘order3’ property instead. Represents sort order of the third key.
setOrder3(SortOrder)@deprecated. Please use the ‘order3’ property instead. Represents sort order of the third key.
getSortLeftToRight()@deprecated. Please use the ‘sortLeftToRight’ property instead. 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.
setSortLeftToRight(boolean)@deprecated. Please use the ‘sortLeftToRight’ property instead. 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.
getCaseSensitive()@deprecated. Please use the ‘caseSensitive’ property instead. Gets and sets whether case sensitive when comparing string.
setCaseSensitive(boolean)@deprecated. Please use the ‘caseSensitive’ property instead. Gets and sets whether case sensitive when comparing string.
getSortAsNumber()@deprecated. Please use the ‘sortAsNumber’ property instead. Indicates whether sorting anything that looks like a number.
setSortAsNumber(boolean)@deprecated. Please use the ‘sortAsNumber’ property instead. Indicates whether sorting anything that looks like a number.
clear()Clear all settings.
addKey(number, SortOrder)Adds sorted column index and sort order.
addKey(number, SortOrder, string)Adds sorted column index and sort order with custom sort list.
addKey(number, SortOnType, SortOrder, Object)Adds sorted column index and sort order with custom sort list.
addKey(number, SortOrder, string[])Adds sorted column index and sort order with custom sort list.
addColorKey(number, SortOnType, SortOrder, Color)Adds color sort key.
sort(Cells, number, number, number, number)Sorts the data of the area.
sort(Cells, CellArea)Sort the data of the area.
sort()Sort the data in the range.
isNull()Checks whether the implementation object is null.

keys

Readonly. Gets the key list of data sorter.

keys : DataSorterKeyCollection;

hasHeaders

Represents whether the range has headers.

hasHeaders : boolean;

key1

Represents first sorted column index(absolute position, column A is 0, B is 1, …).

key1 : number;

order1

Represents sort order of the first key.

order1 : SortOrder;

key2

Represents second sorted column index(absolute position, column A is 0, B is 1, …).

key2 : number;

order2

Represents sort order of the second key.

order2 : SortOrder;

key3

Represents third sorted column index(absolute position, column A is 0, B is 1, …).

key3 : number;

order3

Represents sort order of the third key.

order3 : SortOrder;

sortLeftToRight

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.

sortLeftToRight : boolean;

caseSensitive

Gets and sets whether case sensitive when comparing string.

caseSensitive : boolean;

sortAsNumber

Indicates whether sorting anything that looks like a number.

sortAsNumber : boolean;

getKeys()

@deprecated. Please use the ‘keys’ property instead. Gets the key list of data sorter.

getKeys() : DataSorterKeyCollection;

Returns

DataSorterKeyCollection

getHasHeaders()

@deprecated. Please use the ‘hasHeaders’ property instead. Represents whether the range has headers.

getHasHeaders() : boolean;

setHasHeaders(boolean)

@deprecated. Please use the ‘hasHeaders’ property instead. Represents whether the range has headers.

setHasHeaders(value: boolean) : void;

Parameters:

ParameterTypeDescription
valuebooleanThe value to set.

getKey1()

@deprecated. Please use the ‘key1’ property instead. Represents first sorted column index(absolute position, column A is 0, B is 1, …).

getKey1() : number;

setKey1(number)

@deprecated. Please use the ‘key1’ property instead. Represents first sorted column index(absolute position, column A is 0, B is 1, …).

setKey1(value: number) : void;

Parameters:

ParameterTypeDescription
valuenumberThe value to set.

getOrder1()

@deprecated. Please use the ‘order1’ property instead. Represents sort order of the first key.

getOrder1() : SortOrder;

Returns

SortOrder

setOrder1(SortOrder)

@deprecated. Please use the ‘order1’ property instead. Represents sort order of the first key.

setOrder1(value: SortOrder) : void;

Parameters:

ParameterTypeDescription
valueSortOrderThe value to set.

getKey2()

@deprecated. Please use the ‘key2’ property instead. Represents second sorted column index(absolute position, column A is 0, B is 1, …).

getKey2() : number;

setKey2(number)

@deprecated. Please use the ‘key2’ property instead. Represents second sorted column index(absolute position, column A is 0, B is 1, …).

setKey2(value: number) : void;

Parameters:

ParameterTypeDescription
valuenumberThe value to set.

getOrder2()

@deprecated. Please use the ‘order2’ property instead. Represents sort order of the second key.

getOrder2() : SortOrder;

Returns

SortOrder

setOrder2(SortOrder)

@deprecated. Please use the ‘order2’ property instead. Represents sort order of the second key.

setOrder2(value: SortOrder) : void;

Parameters:

ParameterTypeDescription
valueSortOrderThe value to set.

getKey3()

@deprecated. Please use the ‘key3’ property instead. Represents third sorted column index(absolute position, column A is 0, B is 1, …).

getKey3() : number;

setKey3(number)

@deprecated. Please use the ‘key3’ property instead. Represents third sorted column index(absolute position, column A is 0, B is 1, …).

setKey3(value: number) : void;

Parameters:

ParameterTypeDescription
valuenumberThe value to set.

getOrder3()

@deprecated. Please use the ‘order3’ property instead. Represents sort order of the third key.

getOrder3() : SortOrder;

Returns

SortOrder

setOrder3(SortOrder)

@deprecated. Please use the ‘order3’ property instead. Represents sort order of the third key.

setOrder3(value: SortOrder) : void;

Parameters:

ParameterTypeDescription
valueSortOrderThe value to set.

getSortLeftToRight()

@deprecated. Please use the ‘sortLeftToRight’ property instead. 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.

getSortLeftToRight() : boolean;

setSortLeftToRight(boolean)

@deprecated. Please use the ‘sortLeftToRight’ property instead. 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.

setSortLeftToRight(value: boolean) : void;

Parameters:

ParameterTypeDescription
valuebooleanThe value to set.

getCaseSensitive()

@deprecated. Please use the ‘caseSensitive’ property instead. Gets and sets whether case sensitive when comparing string.

getCaseSensitive() : boolean;

setCaseSensitive(boolean)

@deprecated. Please use the ‘caseSensitive’ property instead. Gets and sets whether case sensitive when comparing string.

setCaseSensitive(value: boolean) : void;

Parameters:

ParameterTypeDescription
valuebooleanThe value to set.

getSortAsNumber()

@deprecated. Please use the ‘sortAsNumber’ property instead. Indicates whether sorting anything that looks like a number.

getSortAsNumber() : boolean;

setSortAsNumber(boolean)

@deprecated. Please use the ‘sortAsNumber’ property instead. Indicates whether sorting anything that looks like a number.

setSortAsNumber(value: boolean) : void;

Parameters:

ParameterTypeDescription
valuebooleanThe value to set.

clear()

Clear all settings.

clear() : void;

addKey(number, SortOrder)

Adds sorted column index and sort order.

addKey(key: number, order: SortOrder) : void;

Parameters:

ParameterTypeDescription
keynumberThe sorted column index(absolute position, column A is 0, B is 1, …)
orderSortOrderThe sort order

addKey(number, SortOrder, string)

Adds sorted column index and sort order with custom sort list.

addKey(key: number, order: SortOrder, customList: string) : void;

Parameters:

ParameterTypeDescription
keynumberThe sorted column index(absolute position, column A is 0, B is 1, …)
orderSortOrderThe sort order.
customListstringThe custom sort list.

addKey(number, SortOnType, SortOrder, Object)

Adds sorted column index and sort order with custom sort list.

addKey(key: number, type: SortOnType, order: SortOrder, customList: Object) : void;

Parameters:

ParameterTypeDescription
keynumberThe sorted column index(absolute position, column A is 0, B is 1, …)
typeSortOnTypeThe sorted value type.
orderSortOrderThe sort order.
customListObjectThe custom sort list.

Remarks

If type is SortOnType.CellColor or SortOnType.FontColor, the customList is Color.

addKey(number, SortOrder, string[])

Adds sorted column index and sort order with custom sort list.

addKey(key: number, order: SortOrder, customList: string[]) : void;

Parameters:

ParameterTypeDescription
keynumberThe sorted column index(absolute position, column A is 0, B is 1, …)
orderSortOrderThe sort order.
customListstring[]The custom sort list.

addColorKey(number, SortOnType, SortOrder, Color)

Adds color sort key.

addColorKey(key: number, type: SortOnType, order: SortOrder, color: Color) : void;

Parameters:

ParameterTypeDescription
keynumberThe sorted column index(absolute position, column A is 0, B is 1, …)
typeSortOnTypeThe sorted color value type.
orderSortOrderThe sort order.
colorColorThe custom sort color.

sort(Cells, number, number, number, number)

Sorts the data of the area.

sort(cells: Cells, startRow: number, startColumn: number, endRow: number, endColumn: number) : number[];

Parameters:

ParameterTypeDescription
cellsCellsThe cells contains the data area.
startRownumberThe start row of the area.
startColumnnumberThe start column of the area.
endRownumberThe end row of the area.
endColumnnumberThe end column of the area.

Returns

the original indices(absolute position, for example, column A is 0, B is 1, …) of the sorted rows/columns. If no rows/columns needs to be moved by this sorting operation, null will be returned.

sort(Cells, CellArea)

Sort the data of the area.

sort(cells: Cells, area: CellArea) : number[];

Parameters:

ParameterTypeDescription
cellsCellsThe cells contains the data area.
areaCellAreaThe area needed to sort

Returns

the original indices(absolute position, for example, column A is 0, B is 1, …) of the sorted rows/columns. If no rows/columns needs to be moved by this sorting operation, null will be returned.

sort()

Sort the data in the range.

sort() : number[];

Returns

the original indices(absolute position, for example, column A is 0, B is 1, …) of the sorted rows/columns. If no rows/columns needs to be moved by this sorting operation, null will be returned.

isNull()

Checks whether the implementation object is null.

isNull() : boolean;