[]
        
(Showing Draft Content)

ISortField

Interface ISortField

All Known Subinterfaces:
ICellColorSortField, IFontColorSortField, IIconSortField, IValueSortField
All Known Implementing Classes:
CellColorSortField, FontColorSortField, IconSortField, SortFieldBase, ValueSortField

public interface ISortField
Represents a sort field.

A sort field defines one sort key within a collection of sort conditions. It specifies the range used as the sort key, the priority used in multi-field sorting, and the sort type represented by a specific subinterface such as value, cell color, font color, or icon sorting. Sort fields are typically managed through ISort.getSortFields().


 worksheet.getRange("A1:B4").setValue(new Object[][] {
     {"Name", "Score"},
     {"Tom", 90},
     {"Amy", 80},
     {"Ken", 95}
 });
 ITable table = worksheet.getTables().add(worksheet.getRange("A1:B4"), true);
 table.getSort().getSortFields().add(new ValueSortField(worksheet.getRange("B1:B4"), SortOrder.Ascending));
 ISortField sortField = table.getSort().getSortFields().get(0);
 sortField.setPriority(1);
 
  • Method Details

    • getKey

      IRange getKey()
      Gets the sort key range.

      Returns the range that represents the sort key for this ISortField.

      
       worksheet.getRange("A1:B4").setValue(new Object[][] {
           {"Name", "Score"},
           {"Tom", 80},
           {"Ada", 95},
           {"Ken", 88}
       });
       ISortField sortField = new ValueSortField(worksheet.getRange("B2:B4"), SortOrder.Ascending);
       IRange key = sortField.getKey();
       
      Returns:
      The range containing the sort key.
    • getPriority

      int getPriority()
      Gets the priority of the ISortField.

      This value specifies the precedence of the sort field when multiple sort fields are used in the same sort operation.

      
       worksheet.getRange("A1:C5").setValue(new Object[][] {
           {"Name", "Score", "Age"},
           {"Alice", 90, 30},
           {"Bob", 85, 28},
           {"Alice", 80, 25},
           {"Bob", 92, 35}
       });
       ISort sort = worksheet.getSort();
       sort.setRange(worksheet.getRange("A1:C5"));
       sort.getSortFields().add(new ValueSortField(worksheet.getRange("A2:A5"), SortOrder.Ascending));
       sort.getSortFields().add(new ValueSortField(worksheet.getRange("B2:B5"), SortOrder.Descending));
       ISortField sortField = sort.getSortFields().get(1);
       sortField.setPriority(1);
       int priority = sortField.getPriority();
       
      Returns:
      The priority of the sort field for a multi-field sort.
    • setPriority

      void setPriority(int value)
      Sets the priority of the ISortField.

      This value specifies the precedence of the sort field when multiple sort fields are used in the same sort operation.

      
       worksheet.getRange("A1:C5").setValue(new Object[][] {
           {"Name", "Score", "Age"},
           {"Alice", 90, 30},
           {"Bob", 85, 28},
           {"Alice", 80, 25},
           {"Bob", 92, 35}
       });
       ISort sort = worksheet.getSort();
       sort.setRange(worksheet.getRange("A1:C5"));
       sort.getSortFields().add(new ValueSortField(worksheet.getRange("A2:A5"), SortOrder.Ascending));
       sort.getSortFields().add(new ValueSortField(worksheet.getRange("B2:B5"), SortOrder.Descending));
       ISortField sortField = sort.getSortFields().get(1);
       sortField.setPriority(1);
       
      Parameters:
      value - The priority of the sort field.
    • getSortOn

      SortOnType getSortOn()
      Gets the sort type.

      This value indicates the criterion used by the sort field, such as values, cell color, font color, or icons.

      
       worksheet.getRange("A1:B4").setValue(new Object[][] {
           {"Name", "Score"},
           {"Tom", 90},
           {"Amy", 80},
           {"Ken", 95}
       });
       ISortField sortField = new ValueSortField(worksheet.getRange("B2:B4"), SortOrder.Ascending);
       SortOnType sortOn = sortField.getSortOn();
       
      Returns:
      The type of criterion used by this sort field.