[]
Gets or sets the formula of the PivotTable field in A1-style notation and in the language of the macro.
This property returns the formula text associated with the field.
string Formula { get; set; }
Property Formula As String
worksheet.Range["A1:B4"].Value = new object[,] {
{"Product", "Amount"},
{"Apple", 100},
{"Banana", 200},
{"Orange", 150}
};
IPivotCache pivotCache = workbook.PivotCaches.Create(worksheet.Range["A1:B4"]);
IPivotTable pivotTable = worksheet.PivotTables.Add(pivotCache, worksheet.Range["D1"], "SalesPivot");
IPivotField field = pivotTable.CalculatedFields.Add("TotalAmount", "=Amount*2");
string formula = field.Formula;