PivotFilter class

PivotFilter class

Represents a PivotFilter in PivotFilter Collection.

The PivotFilter type exposes the following members:

Properties

PropertyDescription
use_whole_dayIndicates whether uses whole days in its filtering criteria.
auto_filterGets the autofilter of the pivot filter.
filter_typeGets the autofilter type of the pivot filter.
field_indexGets the index of source field which this pivot filter is applied to.
filter_categoryGets the category of this filter.
value1Gets the string value1 of the label pivot filter.
value2Gets the string value2 of the label pivot filter.
measure_fld_indexGets the measure field index of the pivot filter.
value_field_indexGets the index of value field in the value region.
measure_cube_field_indexSpecifies the index of the measure cube field.
this property is used only by filters in OLAP pivots and specifies on which measure a value filter should apply.
member_property_field_indexGets the member property field index of the pivot filter.
nameGets the name of the pivot filter.
evaluation_orderGets the Evaluation Order of the pivot filter.

Methods

MethodDescription
get_top_10_valueGets top 10 setting of the filter.
get_labelsGets labels of the caption filter.
get_number_valuesGets values of the number filter.
get_date_time_valuesGets values of the number filter.

Example

from aspose.cells import Workbook
from aspose.cells.pivot import PivotFieldType, PivotFilterType, PivotTableStyleType

book = Workbook()
sheet = book.worksheets[0]
cells = sheet.cells
cells.get(0, 0).value = "fruit"
cells.get(1, 0).value = "grape"
cells.get(2, 0).value = "blueberry"
cells.get(3, 0).value = "kiwi"
cells.get(4, 0).value = "cherry"
cells.get(5, 0).value = "grape"
cells.get(6, 0).value = "blueberry"
cells.get(7, 0).value = "kiwi"
cells.get(8, 0).value = "cherry"
cells.get(0, 1).value = "year"
cells.get(1, 1).value = 2020
cells.get(2, 1).value = 2020
cells.get(3, 1).value = 2020
cells.get(4, 1).value = 2020
cells.get(5, 1).value = 2021
cells.get(6, 1).value = 2021
cells.get(7, 1).value = 2021
cells.get(8, 1).value = 2021
cells.get(0, 2).value = "amount"
cells.get(1, 2).value = 50
cells.get(2, 2).value = 60
cells.get(3, 2).value = 70
cells.get(4, 2).value = 80
cells.get(5, 2).value = 90
cells.get(6, 2).value = 100
cells.get(7, 2).value = 110
cells.get(8, 2).value = 120
pivots = sheet.pivot_tables
pivotIndex = pivots.add("=Sheet1!A1:C9", "A12", "TestPivotTable")
pivot = pivots[pivotIndex]
pivot.add_field_to_area(PivotFieldType.ROW, "fruit")
pivot.add_field_to_area(PivotFieldType.COLUMN, "year")
pivot.add_field_to_area(PivotFieldType.DATA, "amount")
pivot.pivot_table_style_type = PivotTableStyleType.PIVOT_TABLE_STYLE_MEDIUM10
# Add top 10 filter
pivot.base_fields[0].filter_top10(0, PivotFilterType.COUNT, False, 2)
pivot.refresh_data()
pivot.calculate_data()
# do your business
book.save("out.xlsx")

See Also