I'm usingg EPPlus to create a pivot table in excel but I wish show data as percent of the total in one my DataFields, how can I do that?
public static void createTableMotivo(Worksheet ws, ExcelRangeBase range)
{
const string FORMATCURRENCY = "#,###;[Red](#,###)";
ExcelWorksheet worksheet = ws.EPPlusSheet;
//The pivot table
ExcelPivotTable pivotTable = worksheet.PivotTables.Add(worksheet.Cells["B12"], range, "pivot_table1");
//The label row field
pivotTable.RowFields.Add(pivotTable.Fields["FIELD1"]);
pivotTable.DataOnRows = false;
pivotTable.ShowCalcMember = true;
//The data fields
ExcelPivotTableDataField fieldSum = pivotTable.DataFields.Add(pivotTable.Fields["FIELD2"]);
fieldSum.Name = "Quantidade de Faturas";
fieldSum.Function = DataFieldFunctions.Sum;
fieldSum.Format = FORMATCURRENCY;
ExcelPivotTableDataField fieldPercent = pivotTable.DataFields.Add(pivotTable.Fields["FIELD2"]);
fieldPercent.Name = "%";
fieldPercent.Function = DataFieldFunctions.None;
fieldPercent.Format = "0.00%";
pivotTable.PageFields.Add(pivotTable.Fields["FIELD3"]);
pivotTable.PageFields.Add(pivotTable.Fields["FIELD4"]);
}