com.aspose.cells

Class DataSorter

  • java.lang.Object
    • com.aspose.cells.DataSorter
public class DataSorter 
extends java.lang.Object

Summary description for DataSorter.

Example:

//Instantiate a new Workbook object.
Workbook workbook = new Workbook("C:\\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("C:\\outBook.xls");

Property Getters/Setters Summary
booleangetCaseSensitive()
void
setCaseSensitive(booleanvalue)
           Gets and sets whether case sensitive when comparing string.
booleanhasHeaders()
void
setHasHeaders(booleanvalue)
           Represents whether the range has headers.
intgetKey1()
void
setKey1(intvalue)
           Represents first sorted column index(absolute position, column A is 0, B is 1, ...).
intgetKey2()
void
setKey2(intvalue)
           Represents second sorted column index(absolute position, column A is 0, B is 1, ...).
intgetKey3()
void
setKey3(intvalue)
           Represents third sorted column index(absolute position, column A is 0, B is 1, ...).
DataSorterKeyCollectiongetKeys()
Gets the key list of data sorter.
intgetOrder1()
void
setOrder1(intvalue)
           Represents sort order of the first key. The value of the property is SortOrder integer constant.
intgetOrder2()
void
setOrder2(intvalue)
           Represents sort order of the second key. The value of the property is SortOrder integer constant.
intgetOrder3()
void
setOrder3(intvalue)
           Represents sort order of the third key. The value of the property is SortOrder integer constant.
booleangetSortAsNumber()
void
setSortAsNumber(booleanvalue)
           Indicates whether sorting anything that looks like a number.
booleangetSortLeftToRight()
void
setSortLeftToRight(booleanvalue)
           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
voidaddKey(int key, int order)
Adds sorted column index and sort order.
voidaddKey(int key, int type, int order, java.lang.Object customList)
Adds sorted column index and sort order with custom sort list.
voidaddKey(int key, int order, java.lang.String customList)
Adds sorted column index and sort order with custom sort list.
voidaddKey(int key, int order, java.lang.String[] customList)
Adds sorted column index and sort order with custom sort list.
voidclear()
Clear all settings.
voidsort()
Sort the data in the range.
voidsort(Cells cells, CellArea area)
Sort the datas of the area.
voidsort(Cells cells, int startRow, int startColumn, int endRow, int endColumn)
Sorts the data of the area.
 

    • Property Getters/Setters Detail

      • hasHeaders/setHasHeaders

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

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

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

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

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

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

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

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

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

        public boolean getSortAsNumber() / public void setSortAsNumber(boolean value)
        
        Indicates whether sorting anything that looks like a number.

    setHasHeaders

    public voidsetHasHeaders(booleanvalue)
    
    Represents whether the range has headers.

    setKey1

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

    setOrder1

    public voidsetOrder1(intvalue)
    
    Represents sort order of the first key. The value of the property is SortOrder integer constant.

    setKey2

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

    setOrder2

    public voidsetOrder2(intvalue)
    
    Represents sort order of the second key. The value of the property is SortOrder integer constant.

    setKey3

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

    setOrder3

    public voidsetOrder3(intvalue)
    
    Represents sort order of the third key. The value of the property is SortOrder integer constant.

    setSortLeftToRight

    public voidsetSortLeftToRight(booleanvalue)
    
    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.

    setCaseSensitive

    public voidsetCaseSensitive(booleanvalue)
    
    Gets and sets whether case sensitive when comparing string.

    setSortAsNumber

    public voidsetSortAsNumber(booleanvalue)
    
    Indicates whether sorting anything that looks like a number.
    • Method Detail

      • clear

        public void clear()
        Clear all settings.
      • addKey

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

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

        public void addKey(int key, int type, int order, java.lang.Object 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 - The sorted column index(absolute position, column A is 0, B is 1, ...)
        type - A SortOnType value. The sorted value type.
        order - A SortOrder value. The sort order.
        customList - The custom sort list.
      • addKey

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

        public void sort(Cells cells, int startRow, int startColumn, int endRow, int endColumn)
        Sorts the data of the area.
        Parameters:
        cells - The cells contains the data area.
        startRow - The start row of the area.
        startColumn - The start column of the area.
        endRow - The end row of the area.
        endColumn - The end column of the area.
      • sort

        public void sort(Cells cells, CellArea area)
        Sort the datas of the area.
        Parameters:
        cells - The cells contains the data area.
        area - The area needed to sort
      • sort

        public void sort()
        Sort the data in the range.