Class PivotFilter

Class PivotFilter

Namespace: Aspose.Cells.Pivot
Assembly: Aspose.Cells.dll (25.2.0)

Represents a PivotFilter in PivotFilter Collection.

public class PivotFilter

Inheritance

objectPivotFilter

Inherited Members

object.GetType(), object.MemberwiseClone(), object.ToString(), object.Equals(object?), object.Equals(object?, object?), object.ReferenceEquals(object?, object?), object.GetHashCode()

Examples

Workbook book = new Workbook();
Worksheet sheet = book.Worksheets[0];
Cells cells = sheet.Cells;
cells[0, 0].Value = "fruit";
cells[1, 0].Value = "grape";
cells[2, 0].Value = "blueberry";
cells[3, 0].Value = "kiwi";
cells[4, 0].Value = "cherry";
cells[5, 0].Value = "grape";
cells[6, 0].Value = "blueberry";
cells[7, 0].Value = "kiwi";
cells[8, 0].Value = "cherry";

cells[0, 1].Value = "year";
cells[1, 1].Value = 2020;
cells[2, 1].Value = 2020;
cells[3, 1].Value = 2020;
cells[4, 1].Value = 2020;
cells[5, 1].Value = 2021;
cells[6, 1].Value = 2021;
cells[7, 1].Value = 2021;
cells[8, 1].Value = 2021;

cells[0, 2].Value = "amount";
cells[1, 2].Value = 50;
cells[2, 2].Value = 60;
cells[3, 2].Value = 70;
cells[4, 2].Value = 80;
cells[5, 2].Value = 90;
cells[6, 2].Value = 100;
cells[7, 2].Value = 110;
cells[8, 2].Value = 120;

PivotTableCollection pivots = sheet.PivotTables;

int pivotIndex = pivots.Add("=Sheet1!A1:C9", "A12", "TestPivotTable");
PivotTable pivot = pivots[pivotIndex];
pivot.AddFieldToArea(PivotFieldType.Row, "fruit");
pivot.AddFieldToArea(PivotFieldType.Column, "year");
pivot.AddFieldToArea(PivotFieldType.Data, "amount");

pivot.PivotTableStyleType = PivotTableStyleType.PivotTableStyleMedium10;

//Add top 10 filter
 pivot.BaseFields[0].FilterTop10(0, PivotFilterType.Count,false,2);

pivot.RefreshData();
pivot.CalculateData();

//do your business

book.Save("out.xlsx");
Dim book As Workbook = New Workbook()
Dim sheet As Worksheet = book.Worksheets(0)
Dim cells As Cells = sheet.Cells

cells(0, 0).Value = "fruit"
cells(1, 0).Value = "grape"
cells(2, 0).Value = "blueberry"
cells(3, 0).Value = "kiwi"
cells(4, 0).Value = "cherry"
cells(5, 0).Value = "grape"
cells(6, 0).Value = "blueberry"
cells(7, 0).Value = "kiwi"
cells(8, 0).Value = "cherry"

cells(0, 1).Value = "year"
cells(1, 1).Value = 2020
cells(2, 1).Value = 2020
cells(3, 1).Value = 2020
cells(4, 1).Value = 2020
cells(5, 1).Value = 2021
cells(6, 1).Value = 2021
cells(7, 1).Value = 2021
cells(8, 1).Value = 2021

cells(0, 2).Value = "amount"
cells(1, 2).Value = 50
cells(2, 2).Value = 60
cells(3, 2).Value = 70
cells(4, 2).Value = 80
cells(5, 2).Value = 90
cells(6, 2).Value = 100
cells(7, 2).Value = 110
cells(8, 2).Value = 120

Dim pivots As PivotTableCollection = sheet.PivotTables
Dim pivotIndex As Int32 = pivots.Add("=Sheet1!A1:C9", "A12", "TestPivotTable")
Dim pivot As PivotTable = pivots(pivotIndex)
pivot.AddFieldToArea(PivotFieldType.Row, "fruit")
Pivot.AddFieldToArea(PivotFieldType.Column, "year")
Pivot.AddFieldToArea(PivotFieldType.Data, "amount")

pivot.PivotTableStyleType = PivotTableStyleType.PivotTableStyleMedium10

'Add PivotFilter
pivot.BaseFields(0).Filter.FilterTop10(0, PivotFilterType.Count,false,2)

pivot.RefreshData()
pivot.CalculateData()

book.Save("out_vb.xlsx")

Properties

EvaluationOrder

Gets the Evaluation Order of the pivot filter.

public int EvaluationOrder { get; set; }

Property Value

int

FieldIndex

Gets the index of source field which this pivot filter is applied to.

public int FieldIndex { get; }

Property Value

int

FilterCategory

Gets the category of this filter.

public FilterCategory FilterCategory { get; }

Property Value

FilterCategory

FilterType

Gets the autofilter type of the pivot filter.

public PivotFilterType FilterType { get; }

Property Value

PivotFilterType

MeasureCubeFieldIndex

Specifies 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.

public int MeasureCubeFieldIndex { get; }

Property Value

int

MemberPropertyFieldIndex

Gets the member property field index of the pivot filter.

public int MemberPropertyFieldIndex { get; set; }

Property Value

int

Name

Gets the name of the pivot filter.

public string Name { get; set; }

Property Value

string

UseWholeDay

Indicates whether uses whole days in its filtering criteria.

public bool UseWholeDay { get; set; }

Property Value

bool

Value1

Gets the string value1 of the label pivot filter.

public string Value1 { get; set; }

Property Value

string

Value2

Gets the string value2 of the label pivot filter.

public string Value2 { get; set; }

Property Value

string

ValueFieldIndex

Gets the index of value field in the value region.

public int ValueFieldIndex { get; set; }

Property Value

int

Methods

GetDateTimeValues()

Gets values of the number filter.

public DateTime[] GetDateTimeValues()

Returns

DateTime[]

GetLabels()

Gets labels of the caption filter.

public string[] GetLabels()

Returns

string[]

GetNumberValues()

Gets values of the number filter.

public double[] GetNumberValues()

Returns

double[]

GetTop10Value()

Gets top 10 setting of the filter.

public Top10Filter GetTop10Value()

Returns

Top10Filter