1

Closed

Classic PivotTable Layout Not Working

description

Hi,

I am trying to get my pivot tables to display in the classic pivot table layout. Here is my code snippet..

System.Data.DataTable tbl_records = db.GetReportRecords(sheet.SheetQuery);
                var cur_sheet = wb.Worksheets.Add(ReportName);
                var source = cur_sheet.Cell(1, 1).InsertTable(tbl_records, sheet.ReportName, true);
                var range = source.DataRange;
                var header = cur_sheet.Range(1, 1, 1, 3);
                var dataRange = cur_sheet.Range(header.FirstCell(), range.LastCell());

                var ptSheet = wb.Worksheets.Add(sheet.SheetName);

                var pt = ptSheet.PivotTables.AddNew(sheet.SheetName, ptSheet.Cell(1, 1), dataRange);
                 pt.SetClassicPivotTableLayout(true); //Shouldn't this set the pivot to classic layout display??
                pt.SetLayout(XLPivotLayout.Tabular);
                pt.RowLabels.Add("OFFICE");
                pt.RowLabels.Add("UNIT");
                pt.RowLabels.Add("CASELOAD-NUM");
                pt.RowLabels.Add("AID");
                pt.Values.Add("CASELOAD").SummaryFormula = XLPivotSummary.Count;
                pt.SetAutofitColumns(true);
                pt.SetDescription("Division Caseload");
                ptSheet.PivotTable(sheet.SheetName).SetClassicPivotTableLayout(true);
Thanks

Paul
Closed Jan 24 at 2:01 PM by igitur
Please log issues on the new Github page.

comments