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
Method | Description |
---|---|
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) |
addKey(int key, int order)
public void addKey(int key, int order)
Adds sorted column index and sort order.
Parameters:
Parameter | Type | Description |
---|---|---|
key | int | The sorted column index(absolute position, column A is 0, B is 1, …) |
order | int | SortOrder. 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:
Parameter | Type | Description |
---|---|---|
key | int | The sorted column index(absolute position, column A is 0, B is 1, …) |
type | int | SortOnType. The sorted value type. |
order | int | SortOrder. The sort order. |
customList | java.lang.Object | The 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:
Parameter | Type | Description |
---|---|---|
key | int | The sorted column index(absolute position, column A is 0, B is 1, …) |
order | int | SortOrder. The sort order. |
customList | java.lang.String | The 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:
Parameter | Type | Description |
---|---|---|
key | int | The sorted column index(absolute position, column A is 0, B is 1, …) |
order | int | SortOrder. The sort order. |
customList | java.lang.String[] | The custom sort list. |
clear()
public void clear()
Clear all settings.
equals(Object arg0)
public boolean equals(Object arg0)
Parameters:
Parameter | Type | Description |
---|---|---|
arg0 | java.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:
Parameter | Type | Description |
---|---|---|
value | boolean |
setHasHeaders(boolean value)
public void setHasHeaders(boolean value)
Represents whether the range has headers.
Parameters:
Parameter | Type | Description |
---|---|---|
value | boolean |
setKey1(int value)
public void setKey1(int value)
Represents first sorted column index(absolute position, column A is 0, B is 1, …).
Parameters:
Parameter | Type | Description |
---|---|---|
value | int |
setKey2(int value)
public void setKey2(int value)
Represents second sorted column index(absolute position, column A is 0, B is 1, …).
Parameters:
Parameter | Type | Description |
---|---|---|
value | int |
setKey3(int value)
public void setKey3(int value)
Represents third sorted column index(absolute position, column A is 0, B is 1, …).
Parameters:
Parameter | Type | Description |
---|---|---|
value | int |
setOrder1(int value)
public void setOrder1(int value)
Represents sort order of the first key.
See SortOrder.
Parameters:
Parameter | Type | Description |
---|---|---|
value | int |
setOrder2(int value)
public void setOrder2(int value)
Represents sort order of the second key.
See SortOrder.
Parameters:
Parameter | Type | Description |
---|---|---|
value | int |
setOrder3(int value)
public void setOrder3(int value)
Represents sort order of the third key.
See SortOrder.
Parameters:
Parameter | Type | Description |
---|---|---|
value | int |
setSortAsNumber(boolean value)
public void setSortAsNumber(boolean value)
Indicates whether sorting anything that looks like a number.
Parameters:
Parameter | Type | Description |
---|---|---|
value | boolean |
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:
Parameter | Type | Description |
---|---|---|
value | boolean |
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:
Parameter | Type | Description |
---|---|---|
cells | Cells | The cells contains the data area. |
area | CellArea | The 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:
Parameter | Type | Description |
---|---|---|
cells | Cells | The cells contains the data area. |
startRow | int | The start row of the area. |
startColumn | int | The start column of the area. |
endRow | int | The end row of the area. |
endColumn | int | The 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:
Parameter | Type | Description |
---|---|---|
arg0 | long |
wait(long arg0, int arg1)
public final void wait(long arg0, int arg1)
Parameters:
Parameter | Type | Description |
---|---|---|
arg0 | long | |
arg1 | int |