i am able to create a new pivot table and add row fields, data fields etc. using Epplus but when i try to add some calculated fields in pivot table which takes some formula , Epplus doesn't give any option. Is there any way to add calculated fields using Epplus ?
I have tried the following code :
//The pivot table
var pivotTable = pivotSheet.PivotTables.Add(pivotSheet.Cells["A4"], sourceSheet.Cells["A2:V100"], "PivotTable1");
//The label row field
pivotTable.RowFields.Add(pivotTable.Fields["Col1"]);
pivotTable.DataOnRows = false;
//The data fields
var field = pivotTable.DataFields.Add(pivotTable.Fields["Col2"]);
field.Name = "Count of Col2";
field.Function = OfficeOpenXml.Table.PivotTable.DataFieldFunctions.Count;
field = pivotTable.DataFields.Add(pivotTable.Fields["Col3"]);
field.Name = "Count of Col3";
field.Function = OfficeOpenXml.Table.PivotTable.DataFieldFunctions.Count;
Now , i want to add calculated field such as Name of the field = "Sum of Col4" and Formula = "IFError(col5/col6,0)"
in PivotTable1
How to achieve this ?