zhouse28
zhouse28

Reputation: 23

Pivot Table Report layout Show in Tabular Form

What is the C# code to Display Excel Pivot Table layout in Tabular Form?

Here is the code from the Macro that I need converted to C#:

ActiveSheet.PivotTables("PivotTable1").RowAxisLayout xlTabularRow

Here is my starting code to show what variables I have set up:

//Excel.Application excel = new Excel.Application();
activeWorkBook = excel.ActiveWorkbook;
sheets = excel.Sheets;
pivotWorkSheet = (Excel.Worksheet)sheets.Add();

// Create the Pivot Table
pivotCaches = activeWorkBook.PivotCaches();
pivotCache = pivotCaches.Create(Excel.XlPivotTableSourceType.xlDatabase,"Sheet1!$A$2:$J$35");
pivotTable = pivotCache.CreatePivotTable("Sheet2!R2C1");

// Set the Pivot Fields
pivotFields = (Excel.PivotFields)pivotTable.PivotFields();

Upvotes: 1

Views: 2191

Answers (1)

zhouse28
zhouse28

Reputation: 23

I figured it out in case anyone else is looking for this I used:

  pivotTable.RowAxisLayout(Excel.XlLayoutRowType.xlTabularRow);

Upvotes: 1

Related Questions