AutoFilter类
AutoFilter类
表示对指定工作表进行自动筛选。
AutoFilter 类型公开以下成员:
属性
方法
方法 | 描述 |
---|
get_cell_area(self) | 获取此自动筛选器适用的 CellArea 。 |
get_cell_area(self, refresh_applied_range) | 获取指定自动筛选器适用的 CellArea 。 |
remove_filter(self, field_index, criteria) | 删除过滤器列的过滤器。 |
remove_filter(self, field_index) | 删除特定的过滤器。 |
custom(self, field_index, operator_type1, criteria1) | 使用自定义标准过滤列表。 |
custom(self, field_index, operator_type1, criteria1, is_and, operator_type2, criteria2) | 使用自定义标准过滤列表。 |
refresh(self) | 刷新自动过滤器以隐藏或取消隐藏行。 |
refresh(self, hide_rows) | 获取所有隐藏行的索引。 |
set_range(self, row, start_column, end_column) | 设置指定自动筛选适用的范围。 |
add_filter(self, field_index, criteria) | 为过滤列添加过滤器。 |
add_date_filter(self, field_index, date_time_grouping_type, year, month, day, hour, minute, second) | 添加日期过滤器。 |
remove_date_filter(self, field_index, date_time_grouping_type, year, month, day, hour, minute, second) | 删除日期过滤器。 |
filter(self, field_index, criteria) | 使用指定条件过滤列表。 |
filter_top10(self, field_index, is_top, is_percent, item_count) | 筛选列表中的前 10 个项目 |
dynamic_filter(self, field_index, dynamic_filter_type) | 添加动态过滤器。 |
add_font_color_filter(self, field_index, color) | 添加字体颜色过滤器。 |
add_fill_color_filter(self, field_index, pattern, foreground_color, background_color) | 添加填充颜色滤镜。 |
add_icon_filter(self, field_index, icon_set_type, icon_id) | 添加图标过滤器。 |
match_blanks(self, field_index) | 匹配列表中的所有空白单元格。 |
match_non_blanks(self, field_index) | 匹配列表中所有非空白单元格。 |
show_all(self) | 取消隐藏所有行。 |
例子
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")
也可以看看