[]
        
(Showing Draft Content)

GrapeCity.Documents.Excel.IPivotFormulas.Item

this Property

this[int]

Gets the IPivotFormula at the specified index.

Use this property to retrieve a formula from the PivotFormulas collection, such as a formula created by a calculated item in a PivotTable.

Declaration
IPivotFormula this[int index] { get; }
ReadOnly Default Property Item(index As Integer) As IPivotFormula
Parameters
Type Name Description
int index

The index of the pivot formula to retrieve.

Examples
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;
pivotTable.PivotFields["Product"].CalculatedItems().Add("TotalFruit", "=Product[Apple] + Product[Banana]");
IPivotFormula formula = pivotTable.PivotFormulas[0];