asposecells.api

Class DataSorter

Summary description for DataSorter.

Example:

# Instantiate a new Workbook object.
workbook = Workbook("Book2.xlsx")
# Get the workbook datasorter object.
sorter = workbook.getDataSorter()
# Set the first order for datasorter object.
sorter.setOrder1(SortOrder.DESCENDING)
# Define the first key.
sorter.setKey1(0)
# Set the second order for datasorter object.
sorter.setOrder2(SortOrder.ASCENDING)
# Define the second key.
sorter.setKey2(1)
# Create a cells area (range).
ca = 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("Book1.xlsx")

Property Getters/Setters Summary
methodgetCaseSensitive()
method
           Gets and sets whether case sensitive when comparing string.
methodhasHeaders()
method
           Represents whether the range has headers.
methodgetKey1()
method
setKey1(value)
           Represents first sorted column index(absolute position, column A is 0, B is 1, ...).
methodgetKey2()
method
setKey2(value)
           Represents second sorted column index(absolute position, column A is 0, B is 1, ...).
methodgetKey3()
method
setKey3(value)
           Represents third sorted column index(absolute position, column A is 0, B is 1, ...).
methodgetKeys()
Gets the key list of data sorter.
methodgetOrder1()
method
setOrder1(value)
           Represents sort order of the first key. The value of the property is SortOrder integer constant.
methodgetOrder2()
method
setOrder2(value)
           Represents sort order of the second key. The value of the property is SortOrder integer constant.
methodgetOrder3()
method
setOrder3(value)
           Represents sort order of the third key. The value of the property is SortOrder integer constant.
methodgetSortAsNumber()
method
           Indicates whether sorting anything that looks like a number.
methodgetSortLeftToRight()
method
           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.
 
Method Summary
methodaddKey(key, order)
Adds sorted column index and sort order.
methodaddKey(key, type, order, customList)
Adds sorted column index and sort order with custom sort list.
methodaddKey(key, order, customList)
Adds sorted column index and sort order with custom sort list.
methodaddKey(key, order, customList)
Adds sorted column index and sort order with custom sort list.
methodclear()
Clear all settings.
methodsort()
Sort the data in the range.
methodsort(cells, area)
Sort the data of the area.
methodsort(cells, startRow, startColumn, endRow, endColumn)
Sorts the data of the area.
 

    • Property Getters/Setters Detail

      • hasHeaders/setHasHeaders : boolean 

        boolean hasHeaders() / setHasHeaders(value)
        
        Represents whether the range has headers.
      • getKey1/setKey1 : int 

        int getKey1() / setKey1(value)
        
        Represents first sorted column index(absolute position, column A is 0, B is 1, ...).
      • getOrder1/setOrder1 : int 

        int getOrder1() / setOrder1(value)
        
        Represents sort order of the first key. The value of the property is SortOrder integer constant.
      • getKey2/setKey2 : int 

        int getKey2() / setKey2(value)
        
        Represents second sorted column index(absolute position, column A is 0, B is 1, ...).
      • getOrder2/setOrder2 : int 

        int getOrder2() / setOrder2(value)
        
        Represents sort order of the second key. The value of the property is SortOrder integer constant.
      • getKey3/setKey3 : int 

        int getKey3() / setKey3(value)
        
        Represents third sorted column index(absolute position, column A is 0, B is 1, ...).
      • getOrder3/setOrder3 : int 

        int getOrder3() / setOrder3(value)
        
        Represents sort order of the third key. The value of the property is SortOrder integer constant.
      • getSortLeftToRight/setSortLeftToRight : boolean 

        boolean getSortLeftToRight() / setSortLeftToRight(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.
      • getCaseSensitive/setCaseSensitive : boolean 

        boolean getCaseSensitive() / setCaseSensitive(value)
        
        Gets and sets whether case sensitive when comparing string.
      • getSortAsNumber/setSortAsNumber : boolean 

        boolean getSortAsNumber() / setSortAsNumber(value)
        
        Indicates whether sorting anything that looks like a number.
    • Method Detail

      • clear

         clear()
        Clear all settings.
      • addKey

         addKey(key, order)
        Adds sorted column index and sort order.
        Parameters:
        key: int - The sorted column index(absolute position, column A is 0, B is 1, ...)
        order: int - A SortOrder value. The sort order
      • addKey

         addKey(key, order, customList)
        Adds sorted column index and sort order with custom sort list.
        Parameters:
        key: int - The sorted column index(absolute position, column A is 0, B is 1, ...)
        order: int - A SortOrder value. The sort order.
        customList: String - The custom sort list.
      • addKey

         addKey(key, type, order, customList)
        Adds sorted column index and sort order with custom sort list. If type is SortOnType.CellColor or SortOnType.FontColor, the customList is Color.
        Parameters:
        key: int - The sorted column index(absolute position, column A is 0, B is 1, ...)
        type: int - A SortOnType value. The sorted value type.
        order: int - A SortOrder value. The sort order.
        customList: Object - The custom sort list.
      • addKey

         addKey(key, order, customList)
        Adds sorted column index and sort order with custom sort list.
        Parameters:
        key: int - The sorted column index(absolute position, column A is 0, B is 1, ...)
        order: int - A SortOrder value. The sort order.
        customList: String[] - The custom sort list.
      • sort

        int[] sort(cells, startRow, startColumn, endRow, endColumn)
        Sorts the data of the area.
        Parameters:
        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:
        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

        int[] sort(cells, area)
        Sort the data of the area.
        Parameters:
        cells: Cells - The cells contains the data area.
        area: CellArea - The 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

        int[] sort()
        Sort the data in the range.
        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.