[]
Gets the collection of PivotTable fields in the PivotTable report.
The returned IPivotFields collection includes both visible and hidden fields from the PivotTable data source. You can use this collection to access individual fields and configure how they are used in the report layout.
IPivotFields PivotFields { get; }
ReadOnly Property PivotFields As IPivotFields
worksheet.Range["A1:B5"].Value = new object[,] {
{"Category", "Amount"},
{"Fruit", 120},
{"Fruit", 80},
{"Vegetables", 95},
{"Vegetables", 60}
};
IPivotCache pivotCache = workbook.PivotCaches.Create(worksheet.Range["A1:B5"]);
IPivotTable pivotTable = worksheet.PivotTables.Add(pivotCache, worksheet.Range["D1"], "SalesPivot");
IPivotFields pivotFields = pivotTable.PivotFields;
pivotFields["Category"].Orientation = PivotFieldOrientation.RowField;