[]
Gets the collection of formulas for the specified PivotTable report.
Use this property to access the IPivotFormulas collection that contains the custom formulas defined for the PivotTable, such as formulas created by calculated items.
IPivotFormulas PivotFormulas { get; }
ReadOnly Property PivotFormulas As IPivotFormulas
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]");
IPivotFormulas formulas = pivotTable.PivotFormulas;
IPivotFormula formula = formulas[0];