简体   繁体   English

数据透视表报表布局以表格形式显示

[英]Pivot Table Report layout Show in Tabular Form

What is the C# code to Display Excel Pivot Table layout in Tabular Form? 以表格形式显示Excel数据透视表布局的C#代码是什么?

Here is the code from the Macro that I need converted to C#: 这是我需要将宏转换为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();

我弄清楚了,以防万一其他人正在寻找我使用过的东西:

  pivotTable.RowAxisLayout(Excel.XlLayoutRowType.xlTabularRow);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM