[]
A collection of IPivotItem objects that represent all the calculated items in the specified PivotTable report.
Use this interface to access, add, and remove calculated items for a pivot field. Obtain an instance from CalculatedItems().
public interface ICalculatedItems : IEnumerable<IPivotItem>, IEnumerable
Public Interface ICalculatedItems
Inherits IEnumerable(Of IPivotItem), IEnumerable
worksheet.Range["A1:C4"].Value = new object[,] {
{"Product", "Category", "Amount"},
{"Apple", "Fruit", 120},
{"Banana", "Fruit", 80},
{"Bran", "Snack", 60}
};
IPivotCache pivotCache = workbook.PivotCaches.Create(worksheet.Range["A1:C4"]);
IPivotTable pivotTable = worksheet.PivotTables.Add(pivotCache, worksheet.Range["E1"], "SalesPivot");
pivotTable.PivotFields["Product"].Orientation = PivotFieldOrientation.RowField;
pivotTable.PivotFields["Amount"].Orientation = PivotFieldOrientation.DataField;
pivotTable.PivotFields["Category"].Orientation = PivotFieldOrientation.ColumnField;
ICalculatedItems calculatedItems = pivotTable.PivotFields["Product"].CalculatedItems();
IPivotItem item = calculatedItems.Add("TotalFruit", "=Product[Apple] + Product[Banana]");
| Name | Description |
|---|---|
| Count | Returns the number of IPivotItem objects in the collection.
This value represents the total number of calculated items defined for the associated pivot field.
Returns |
| this[int] | Gets the IPivotItem at the specified index. Use this property to retrieve a calculated item from the collection returned by CalculatedItems(). |
| this[string] | Gets the IPivotItem item by name. Use this property to retrieve a calculated item from the ICalculatedItems collection of a pivot field. |
| Name | Description |
|---|---|
| Add(string, string) | Creates a new calculated item. Returns a IPivotItem object. Use the returned item to access the calculated item after it is added to the pivot field's calculated items collection obtained from CalculatedItems(). |
| Remove(string) | Removes the calculated item with the specified name. This method removes a calculated item from the current ICalculatedItems collection obtained from CalculatedItems(). Item name matching is case-insensitive. If no calculated item with the specified name exists, this method does nothing. |