[]
Gets the data field that the pivot filter depends on.
For value-based pivot filters, this property returns the data field used to
evaluate the filter. For filters that do not depend on a data field, such as
label filters, this property returns null.
IPivotField DataField { get; }
ReadOnly Property DataField As IPivotField
worksheet.Range["A1:C5"].Value = new object[,] {
{"Product", "Category", "Amount"},
{"Apple", "Fruit", 120},
{"Banana", "Fruit", 80},
{"Carrot", "Vegetable", 95},
{"Beans", "Vegetable", 110}
};
IPivotCache pivotCache = workbook.PivotCaches.Create(worksheet.Range["A1:C5"]);
IPivotTable pivotTable = worksheet.PivotTables.Add(pivotCache, worksheet.Range["E1"], "SalesPivot");
pivotTable.PivotFields["Category"].Orientation = PivotFieldOrientation.RowField;
pivotTable.PivotFields["Amount"].Orientation = PivotFieldOrientation.DataField;
PivotFilterOptions options = new PivotFilterOptions();
options.AppliedDataField = 0;
IPivotFilter filter = pivotTable.PivotFields["Category"].PivotFilters.Add(PivotFilterType.ValueGreaterThan, 100, null, options);
IPivotField dataField = filter.DataField;