public final class SortLevel extends Object implements com.gembox.spreadsheet.internal.styles.CellFormatDataFormatHolder
Following methods shows various ways to specify and apply a SortState to a range of cells.
public static void sort1(ExcelWorksheet worksheet) {
// Specify and apply Sort using less-verbose, fluent, but less understandable interface.
worksheet.getCells().getSubrange("A1", "D20").sort(true).
by(0).
by(1, true).
by(2, "Female", "Male").
apply();
}
public static void sort2(ExcelWorksheet worksheet) {
// Specify and apply Sort using more verbose, but more understandable interface.
SortState sort = worksheet.getCells().getSubrange("A1", "D20").sort(true);
sort.getLevels().add(0);
SortLevel level2 = sort.getLevels().add(1);
level2.setDescending(true);
SortLevel level3 = sort.getLevels().add(2);
level3.setCustomList("Female", "Male");
sort.apply();
}
Modifier and Type | Method and Description |
---|---|
int |
getColumnRowIndex()
Gets the column (or the row, if
SortState.isLeftToRight() is true ) index relative to the range that this sort level applies to. |
Comparator<ExcelCell> |
getComparator()
Gets the comparison method that compares two
ExcelCell s. |
List<String> |
getCustomList()
Gets the custom list by which order of items to sort by.
|
boolean |
isDescending()
Gets a value indicating whether to sort the values in the descending order.
|
void |
setColumnRowIndex(int value)
Sets the column (or the row, if
SortState.isLeftToRight() is true ) index relative to the range that this sort level applies to. |
void |
setComparator(Comparator<ExcelCell> value)
Sets the comparison method that compares two
ExcelCell s. |
void |
setCustomList(Iterable<String> items)
Sets the custom list by which order of items to sort by.
|
void |
setCustomList(String... items)
Sets the custom list by which order of items to sort by.
|
void |
setDescending(boolean value)
Sets a value indicating whether to sort the values in the descending order.
|
String |
toString()
Returns a
String that represents this SortLevel instance. |
public int getColumnRowIndex()
Gets the column (or the row, if SortState.isLeftToRight()
is true
) index relative to the range
that this sort level applies to.
Value is equal to or greater than zero and less than width
(or height
, if SortState.isLeftToRight()
is true
) of the range
.
SortState.isLeftToRight()
is true
) index relative to the range
that this sort level applies to.public Comparator<ExcelCell> getComparator()
Gets the comparison method that compares two ExcelCell
s.
Default value is default comparison method based on the settings of this sort level.
This member is not loaded from and saved to XLSX file since it is not supported by Office Open XML specification. It is used to customize GemBox.Spreadsheet functionality.
ExcelCell
s.public List<String> getCustomList()
Gets the custom list by which order of items to sort by.
If isDescending()
is set to true
, then sorting will be performed based on the reverse order of items.
public boolean isDescending()
Gets a value indicating whether to sort the values in the descending order.
Default value is false
.
true
to sort the values in the descending order; otherwise, false
.public void setColumnRowIndex(int value)
Sets the column (or the row, if SortState.isLeftToRight()
is true
) index relative to the range
that this sort level applies to.
Value is equal to or greater than zero and less than width
(or height
, if SortState.isLeftToRight()
is true
) of the range
.
value
- The column (or the row, if SortState.isLeftToRight()
is true
) index relative to the range
that this sort level applies to.IllegalStateException
- Sort level is removed from the sort state.IndexOutOfBoundsException
- Value is less than zero or is equal to or greater than width
(or height
, if SortState.isLeftToRight()
is true
) of the range
.IllegalArgumentException
- Column/row at the specified index is being sorted by the same criteria more than once. Delete the duplicate sort criteria and try again.public void setComparator(Comparator<ExcelCell> value)
Sets the comparison method that compares two ExcelCell
s.
Default value is default comparison method based on the settings of this sort level.
Use this method to override default comparison method based on the settings of this sort level.
This member is not loaded from and saved to XLSX file since it is not supported by Office Open XML specification. It is used to customize GemBox.Spreadsheet functionality.
If set to null
, reverts to default comparison method based on the settings of this sort level.
value
- The comparison method that compares two ExcelCell
s.public void setCustomList(Iterable<String> items)
Sets the custom list by which order of items to sort by.
items
- The custom list by which order of items to sort by.public void setCustomList(String... items)
Sets the custom list by which order of items to sort by.
items
- The custom list by which order of items to sort by.public void setDescending(boolean value)
Sets a value indicating whether to sort the values in the descending order.
Default value is false
.
value
- true
to sort the values in the descending order; otherwise, false
.© GemBox d.o.o. — All rights reserved.