DataSorter

Inheritance: java.lang.Object

public class DataSorter

Summary description for DataSorter.

Example

         //Instantiate a new Workbook object.
         Workbook workbook = new Workbook("Book1.xls");
         //Get the workbook datasorter object.
         DataSorter sorter = workbook.getDataSorter();
         //Set the first order for datasorter object.
         sorter.setOrder1(com.aspose.cells.SortOrder.DESCENDING);
         //Define the first key.
         sorter.setKey1(0);
         //Set the second order for datasorter object.
         sorter.setOrder2(com.aspose.cells.SortOrder.ASCENDING);
         //Define the second key.
         sorter.setKey2(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.getWorksheets().get(0).getCells(), ca);
         //Save the excel file.
         workbook.save("outBook.xls");

Methods

MethodDescription
addColorKey(int key, int type, int order, Color color)Adds color sort key.
addKey(int key, int order)Adds sorted column index and sort order.
addKey(int key, int type, int order, Object customList)Adds sorted column index and sort order with custom sort list.
addKey(int key, int order, String customList)Adds sorted column index and sort order with custom sort list.
addKey(int key, int order, String[] customList)Adds sorted column index and sort order with custom sort list.
clear()Clear all settings.
equals(Object arg0)
getCaseSensitive()Gets whether case sensitive when comparing string.
getClass()
getKey1()Represents first sorted column index(absolute position, column A is 0, B is 1, …).
getKey2()Represents second sorted column index(absolute position, column A is 0, B is 1, …).
getKey3()Represents third sorted column index(absolute position, column A is 0, B is 1, …).
getKeys()Gets the key list of data sorter.
getOrder1()Represents sort order of the first key.
getOrder2()Represents sort order of the second key.
getOrder3()Represents sort order of the third key.
getSortAsNumber()Indicates whether sorting anything that looks like a number.
getSortLeftToRight()True means that sorting orientation is from left to right.
hasHeaders()Represents whether the range has headers.
hashCode()
notify()
notifyAll()
setCaseSensitive(boolean value)Sets whether case sensitive when comparing string.
setHasHeaders(boolean value)Represents whether the range has headers.
setKey1(int value)Represents first sorted column index(absolute position, column A is 0, B is 1, …).
setKey2(int value)Represents second sorted column index(absolute position, column A is 0, B is 1, …).
setKey3(int value)Represents third sorted column index(absolute position, column A is 0, B is 1, …).
setOrder1(int value)Represents sort order of the first key.
setOrder2(int value)Represents sort order of the second key.
setOrder3(int value)Represents sort order of the third key.
setSortAsNumber(boolean value)Indicates whether sorting anything that looks like a number.
setSortLeftToRight(boolean value)True means that sorting orientation is from left to right.
sort()Sort the data in the range.
sort(Cells cells, CellArea area)Sort the data of the area.
sort(Cells cells, int startRow, int startColumn, int endRow, int endColumn)Sorts the data of the area.
toString()
wait()
wait(long arg0)
wait(long arg0, int arg1)

addColorKey(int key, int type, int order, Color color)

public void addColorKey(int key, int type, int order, Color color)

Adds color sort key.

Parameters:

ParameterTypeDescription
keyintThe sorted column index(absolute position, column A is 0, B is 1, …)
typeintSortOnType. The sorted color value type.
orderintSortOrder. The sort order.
colorColorThe custom sort color.

addKey(int key, int order)

public void addKey(int key, int order)

Adds sorted column index and sort order.

Parameters:

ParameterTypeDescription
keyintThe sorted column index(absolute position, column A is 0, B is 1, …)
orderintSortOrder. The sort order

addKey(int key, int type, int order, Object customList)

public void addKey(int key, int type, int order, Object customList)

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

Remarks

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

Parameters:

ParameterTypeDescription
keyintThe sorted column index(absolute position, column A is 0, B is 1, …)
typeintSortOnType. The sorted value type.
orderintSortOrder. The sort order.
customListjava.lang.ObjectThe custom sort list.

addKey(int key, int order, String customList)

public void addKey(int key, int order, String customList)

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

Parameters:

ParameterTypeDescription
keyintThe sorted column index(absolute position, column A is 0, B is 1, …)
orderintSortOrder. The sort order.
customListjava.lang.StringThe custom sort list.

addKey(int key, int order, String[] customList)

public void addKey(int key, int order, String[] customList)

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

Parameters:

ParameterTypeDescription
keyintThe sorted column index(absolute position, column A is 0, B is 1, …)
orderintSortOrder. The sort order.
customListjava.lang.String[]The custom sort list.

clear()

public void clear()

Clear all settings.

equals(Object arg0)

public boolean equals(Object arg0)

Parameters:

ParameterTypeDescription
arg0java.lang.Object

Returns: boolean

getCaseSensitive()

public boolean getCaseSensitive()

Gets whether case sensitive when comparing string.

Returns: boolean

getClass()

public final native Class<?> getClass()

Returns: java.lang.Class

getKey1()

public int getKey1()

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

Returns: int

getKey2()

public int getKey2()

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

Returns: int

getKey3()

public int getKey3()

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

Returns: int

getKeys()

public DataSorterKeyCollection getKeys()

Gets the key list of data sorter.

Returns: DataSorterKeyCollection

getOrder1()

public int getOrder1()

Represents sort order of the first key.

See SortOrder.

Returns: int

getOrder2()

public int getOrder2()

Represents sort order of the second key.

See SortOrder.

Returns: int

getOrder3()

public int getOrder3()

Represents sort order of the third key.

See SortOrder.

Returns: int

getSortAsNumber()

public boolean getSortAsNumber()

Indicates whether sorting anything that looks like a number.

Returns: boolean

getSortLeftToRight()

public boolean getSortLeftToRight()

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.

Returns: boolean

hasHeaders()

public boolean hasHeaders()

Represents whether the range has headers.

Returns: boolean

hashCode()

public native int hashCode()

Returns: int

notify()

public final native void notify()

notifyAll()

public final native void notifyAll()

setCaseSensitive(boolean value)

public void setCaseSensitive(boolean value)

Sets whether case sensitive when comparing string.

Parameters:

ParameterTypeDescription
valueboolean

setHasHeaders(boolean value)

public void setHasHeaders(boolean value)

Represents whether the range has headers.

Parameters:

ParameterTypeDescription
valueboolean

setKey1(int value)

public void setKey1(int value)

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

Parameters:

ParameterTypeDescription
valueint

setKey2(int value)

public void setKey2(int value)

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

Parameters:

ParameterTypeDescription
valueint

setKey3(int value)

public void setKey3(int value)

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

Parameters:

ParameterTypeDescription
valueint

setOrder1(int value)

public void setOrder1(int value)

Represents sort order of the first key.

See SortOrder.

Parameters:

ParameterTypeDescription
valueint

setOrder2(int value)

public void setOrder2(int value)

Represents sort order of the second key.

See SortOrder.

Parameters:

ParameterTypeDescription
valueint

setOrder3(int value)

public void setOrder3(int value)

Represents sort order of the third key.

See SortOrder.

Parameters:

ParameterTypeDescription
valueint

setSortAsNumber(boolean value)

public void setSortAsNumber(boolean value)

Indicates whether sorting anything that looks like a number.

Parameters:

ParameterTypeDescription
valueboolean

setSortLeftToRight(boolean value)

public void setSortLeftToRight(boolean value)

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.

Parameters:

ParameterTypeDescription
valueboolean

sort()

public int[] sort()

Sort the data in the range.

Returns: int[] - 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 cells, CellArea area)

public int[] sort(Cells cells, CellArea area)

Sort the data of the area.

Parameters:

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

Returns: int[] - 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 cells, int startRow, int startColumn, int endRow, int endColumn)

public int[] sort(Cells cells, int startRow, int startColumn, int endRow, int endColumn)

Sorts the data of the area.

Parameters:

ParameterTypeDescription
cellsCellsThe cells contains the data area.
startRowintThe start row of the area.
startColumnintThe start column of the area.
endRowintThe end row of the area.
endColumnintThe end column of the area.

Returns: int[] - 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.

toString()

public String toString()

Returns: java.lang.String

wait()

public final void wait()

wait(long arg0)

public final native void wait(long arg0)

Parameters:

ParameterTypeDescription
arg0long

wait(long arg0, int arg1)

public final void wait(long arg0, int arg1)

Parameters:

ParameterTypeDescription
arg0long
arg1int