[]
A collection of IPivotField objects that represents all the calculated fields in the specified PivotTable report.
Use this collection to access, add, and remove calculated fields for a PivotTable. Each item in the collection represents a calculated field defined in the PivotTable report.
public interface ICalculatedFields : IEnumerable<IPivotField>, IEnumerable
Public Interface ICalculatedFields
Inherits IEnumerable(Of IPivotField), IEnumerable
worksheet.Range["A1:B4"].Value = new object[,] {
{"Product", "Amount"},
{"Apple", 120},
{"Orange", 90},
{"Apple", 80}
};
IPivotCache pivotCache = workbook.PivotCaches.Create(worksheet.Range["A1:B4"]);
IPivotTable pivotTable = worksheet.PivotTables.Add(pivotCache, worksheet.Range["D1"], "SalesPivot");
ICalculatedFields calculatedFields = pivotTable.CalculatedFields;
calculatedFields.Add("DoubleAmount", "=Amount*2");
| Name | Description |
|---|---|
| Count | Returns the number of calculated fields. This property returns the number of calculated fields in the collection returned by CalculatedFields for a PivotTable report. |
| this[int] | Gets the calculated field at the specified index. Use this property to retrieve a calculated field from the collection returned by CalculatedFields. |
| this[string] | Gets the calculated field by name. Use this property to retrieve a calculated field from the collection returned by CalculatedFields. |
| Name | Description |
|---|---|
| Add(string, string) | Creates a new calculated field. Returns a IPivotField object. Use this method to add a custom formula-based field to a PivotTable when built-in summary functions are not sufficient. The formula corresponds to the Formula value of the created field. |
| Remove(string) | Removes the calculated fields by name. Use this method to delete a calculated field from the calculated field collection of a PivotTable. |