[]
Gets the collection of fields that are currently shown as data fields in the PivotTable report.
The returned collection is read-only and contains the fields placed in the Values area of the PivotTable.
IPivotFields DataFields { get; }
ReadOnly Property DataFields As IPivotFields
worksheet.Range["A1:B4"].Value = new object[,] {
{"Category", "Amount"},
{"Fruit", 100},
{"Fruit", 80},
{"Vegetables", 60}
};
IPivotCache pivotCache = workbook.PivotCaches.Create(worksheet.Range["A1:B4"]);
IPivotTable pivotTable = worksheet.PivotTables.Add(pivotCache, worksheet.Range["D1"], "SalesPivot");
pivotTable.AddDataField(pivotTable.PivotFields["Amount"], "Sum of Amount", ConsolidationFunction.Sum);
IPivotFields dataFields = pivotTable.DataFields;
string caption = dataFields[0].Name;