Example:
# Instantiating a Workbook object workbook = Workbook("Book2.xlsx") # Accessing the first worksheet in the Excel file worksheet = workbook.getWorksheets().get(0) # Creating AutoFilter by giving the cells range of the heading row worksheet.getAutoFilter().setRange("A1:B1") # Filtering columns with specified values worksheet.getAutoFilter().filter(1, "Bananas") # Saving the modified Excel file. workbook.save("Book2.xls")
Property Getters/Setters Summary | ||
---|---|---|
method | getFilterColumns() | |
Gets the collection of the filter columns.
|
||
method | getRange() | |
method | setRange(value) | |
Represents the range to which the specified AutoFilter applies. | ||
method | getShowFilterButton() | |
method | setShowFilterButton(value) | |
Indicates whether the AutoFilter button for this column is visible. | ||
method | getSorter() | |
Gets the data sorter.
|
Method Summary | ||
---|---|---|
method | addDateFilter(fieldIndex, dateTimeGroupingType, year, month, day, hour, minute, second) | |
Adds a date filter.
|
||
method | addFillColorFilter(fieldIndex, pattern, foregroundColor, backgroundColor) | |
Adds a fill color filter.
|
||
method | addFilter(fieldIndex, criteria) | |
Adds a filter for a filter column.
|
||
method | addFontColorFilter(fieldIndex, color) | |
Adds a font color filter.
|
||
method | addIconFilter(fieldIndex, iconSetType, iconId) | |
Adds an icon filter.
|
||
method | custom(fieldIndex, operatorType1, criteria1) | |
Filters a list with a custom criteria.
|
||
method | custom(fieldIndex, operatorType1, criteria1, isAnd, operatorType2, criteria2) | |
Filters a list with custom criteria.
|
||
method | dynamicFilter(fieldIndex, dynamicFilterType) | |
Adds a dynamic filter.
|
||
method | filter(fieldIndex, criteria) | |
Filters a list with specified criteria.
|
||
method | filterTop10(fieldIndex, isTop, isPercent, itemCount) | |
Filter the top 10 item in the list
|
||
method | getCellArea() | |
Gets the |
||
method | matchBlanks(fieldIndex) | |
Match all blank cell in the list.
|
||
method | matchNonBlanks(fieldIndex) | |
Match all not blank cell in the list.
|
||
method | refresh() | |
Refresh auto filters to hide or unhide the rows.
|
||
method | refresh(hideRows) | |
Gets all hidden rows' indexes.
|
||
method | removeDateFilter(fieldIndex, dateTimeGroupingType, year, month, day, hour, minute, second) | |
Removes a date filter.
|
||
method | removeFilter(fieldIndex) | |
Remove the specific filter.
|
||
method | removeFilter(fieldIndex, criteria) | |
Removes a filter for a filter column.
|
||
method | setRange(row, startColumn, endColumn) | |
Sets the range to which the specified AutoFilter applies.
|
||
method | showAll() | |
Unhide all rows.
|
DataSorter getSorter()
String getRange() / setRange(value)
boolean getShowFilterButton() / setShowFilterButton(value)
FilterColumnCollection getFilterColumns()
setRange(row, startColumn, endColumn)
row: int
- Row index.startColumn: int
- Start column index.endColumn: int
- End column Index.CellArea getCellArea()
addFilter(fieldIndex, criteria)
fieldIndex: int
- The integer offset of the field on which you want to base the filter
(from the left of the list; the leftmost field is field 0).
criteria: String
- The specified criteria (a string; for example, "101").
It only can be null or be one of the cells' value in this column.
addDateFilter(fieldIndex, dateTimeGroupingType, year, month, day, hour, minute, second)
fieldIndex: int
- The integer offset of the field on which you want to base the filter
(from the left of the list; the leftmost field is field 0).
dateTimeGroupingType: int
- A year: int
- The year.month: int
- The month.day: int
- The day.hour: int
- The hour.minute: int
- The minute.second: int
- The second.removeDateFilter(fieldIndex, dateTimeGroupingType, year, month, day, hour, minute, second)
fieldIndex: int
- The integer offset of the field on which you want to base the filter
(from the left of the list; the leftmost field is field 0).
dateTimeGroupingType: int
- A year: int
- The year.month: int
- The month.day: int
- The day.hour: int
- The hour.minute: int
- The minute.second: int
- The second.removeFilter(fieldIndex, criteria)
fieldIndex: int
- The integer offset of the field on which you want to base the filter
(from the left of the list; the leftmost field is field 0).
criteria: String
- The specified criteria (a string; for example, "101").
It only can be null or be one of the cells' value in this column.
filter(fieldIndex, criteria)
fieldIndex: int
- The integer offset of the field on which you want to base the filter
(from the left of the list; the leftmost field is field 0).
criteria: String
- The specified criteria (a string; for example, "101"). filterTop10(fieldIndex, isTop, isPercent, itemCount)
fieldIndex: int
- The integer offset of the field on which you want to base the filter
(from the left of the list; the leftmost field is field 0).isTop: boolean
- Indicates whether filter from top or bottomisPercent: boolean
- Indicates whether the items is percent or count itemCount: int
- The item countdynamicFilter(fieldIndex, dynamicFilterType)
fieldIndex: int
- The integer offset of the field on which you want to base the filter
(from the left of the list; the leftmost field is field 0).dynamicFilterType: int
- A addFontColorFilter(fieldIndex, color)
fieldIndex: int
- The integer offset of the field on which you want to base the filter
(from the left of the list; the leftmost field is field 0).color: CellsColor
- The addFillColorFilter(fieldIndex, pattern, foregroundColor, backgroundColor)
fieldIndex: int
- The integer offset of the field on which you want to base the filter
(from the left of the list; the leftmost field is field 0).pattern: int
- A foregroundColor: CellsColor
- The foreground color.backgroundColor: CellsColor
- The background color.addIconFilter(fieldIndex, iconSetType, iconId)
fieldIndex: int
- The integer offset of the field on which you want to base the filter
(from the left of the list; the leftmost field is field 0).iconSetType: int
- A iconId: int
- The icon id.matchBlanks(fieldIndex)
fieldIndex: int
- The integer offset of the field on which you want to base the filter
(from the left of the list; the leftmost field is field 0).matchNonBlanks(fieldIndex)
fieldIndex: int
- The integer offset of the field on which you want to base the filter
(from the left of the list; the leftmost field is field 0).custom(fieldIndex, operatorType1, criteria1)
fieldIndex: int
- The integer offset of the field on which you want to base the filter
(from the left of the list; the leftmost field is field 0).operatorType1: int
- A criteria1: Object
- The custom criteriacustom(fieldIndex, operatorType1, criteria1, isAnd, operatorType2, criteria2)
fieldIndex: int
- The integer offset of the field on which you want to base the filter
(from the left of the list; the leftmost field is field 0).operatorType1: int
- A criteria1: Object
- The custom criteriaisAnd: boolean
- operatorType2: int
- A criteria2: Object
- The custom criteriashowAll()
removeFilter(fieldIndex)
fieldIndex: int
- The specific filter indexint[] refresh()
int[] refresh(hideRows)
hideRows: boolean
-
If true, hide the filtered rows.