AutoFilter class

AutoFilter class

Represents autofiltering for the specified worksheet.

The AutoFilter type exposes the following members:

Properties

PropertyDescription
sorterGets the data sorter.
rangeRepresents the range to which the specified AutoFilter applies.
show_filter_buttonIndicates whether the AutoFilter button for this column is visible.
filter_columnsGets the collection of the filter columns.

Methods

MethodDescription
get_cell_area(self)Gets the CellArea where the this AutoFilter applies to.
get_cell_area(self, refresh_applied_range)Gets the CellArea where the specified AutoFilter applies to.
remove_filter(self, field_index, criteria)Removes a filter for a filter column.
remove_filter(self, field_index)Remove the specific filter.
custom(self, field_index, operator_type1, criteria1)Filters a list with a custom criteria.
custom(self, field_index, operator_type1, criteria1, is_and, operator_type2, criteria2)Filters a list with custom criteria.
refresh(self)Refresh auto filters to hide or unhide the rows.
refresh(self, hide_rows)Gets all hidden rows’ indexes.
set_range(self, row, start_column, end_column)Sets the range to which the specified AutoFilter applies.
add_filter(self, field_index, criteria)Adds a filter for a filter column.
add_date_filter(self, field_index, date_time_grouping_type, year, month, day, hour, minute, second)Adds a date filter.
remove_date_filter(self, field_index, date_time_grouping_type, year, month, day, hour, minute, second)Removes a date filter.
filter(self, field_index, criteria)Filters a list with specified criteria.
filter_top10(self, field_index, is_top, is_percent, item_count)Filter the top 10 item in the list
dynamic_filter(self, field_index, dynamic_filter_type)Adds a dynamic filter.
add_font_color_filter(self, field_index, color)Adds a font color filter.
add_fill_color_filter(self, field_index, pattern, foreground_color, background_color)Adds a fill color filter.
add_icon_filter(self, field_index, icon_set_type, icon_id)Adds an icon filter.
match_blanks(self, field_index)Match all blank cell in the list.
match_non_blanks(self, field_index)Match all not blank cell in the list.
show_all(self)Unhide all rows.

Example

from aspose.cells import Workbook

# Creating a file stream containing the Excel file to be opened
# Instantiating a Workbook object
workbook = Workbook("template.xlsx")
# Accessing the first worksheet in the Excel file
worksheet = workbook.worksheets[0]
# Creating AutoFilter by giving the cells range of the heading row
worksheet.auto_filter.range = "A1:B1"
# Filtering columns with specified values
worksheet.auto_filter.filter(1, "Bananas")
# Saving the modified Excel file.
workbook.save("output.xls")

See Also