Quantcast
Channel: ClosedXML - The easy way to OpenXML
Viewing all articles
Browse latest Browse all 1877

Closed Unassigned: Classic PivotTable Layout Not Working [9504]

$
0
0
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
Comments: Please log issues on the new Github page.

Viewing all articles
Browse latest Browse all 1877

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>