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