Good day,
I need to export a plain Excel table with several columns. Based on this table I want to build a Pivot table on the second sheet. One of the columns has dates. If I add this field in the list of Pivot fields manually in Excel, also two additional columns for year and quater are selected as rows.
How can I achieve this with XlsIo?
...
var pivotSheet = workbook.Worksheets[0];
IPivotCache cache = workbook.PivotCaches.Add(sheet.Range[1, 1, row - 1, maxCol]);
IPivotTable pivotTable = pivotSheet.PivotTables.Add("PivotTable1", pivotSheet["A1"], cache);
pivotTable.Fields[1].Axis = PivotAxisTypes.Row; // Created <- the date column
pivotTable.Fields[2].Axis = PivotAxisTypes.Page; // Costcenter
pivotTable.Fields[10].Axis = PivotAxisTypes.Row; // Creator
pivotTable.Fields[17].Axis = PivotAxisTypes.Column; // Status
var iDField = pivotTable.Fields[0];
pivotTable.DataFields.Add(iDField, "Count", PivotSubtotalTypes.Count);
...
Thanks
Christian