Reputation: 31
Currently have a project where I am dumping a result set of data to an excel and creating pivot table with this raw data using Closed XML
I cannot seem to get the report Layout to set and persist as tabular
Below is a sample of the code I am using to implement this
var ptSheet = wb.Worksheets.Add("PivotTable");
var pt = ptSheet.PivotTables.Add("PivotTable", ptSheet.Cell(1, 1), range);
pt.SetLayout(XLPivotLayout.Tabular);
pt.Layout = XLPivotLayout.Tabular;
'SetLayout' & 'Layout' seem to make no changes to the layout of the pivot on save of the excel. Are other settings required to be toggled?
Upvotes: 0
Views: 1014
Reputation: 31
Just adding this solution in case someone has similar issue.
I found adding the following line of code to my above example made the pivot table layout appear as tabular
pt.ClassicPivotTableLayout = true;
Not the most elegant solution but works for my use case
Upvotes: 3