Page tree

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Excerpt

Sets or returns the layout option for the pivot table.

Signature
0csharp
public PivotTableLayout.LayoutOptions ReportLayout { get; set; }
Signature
vb.net
vb.net
Public Property ReportLayout() As LayoutOptionPivotTableLayout.LayoutOptions
Example
Code Block
csharp
csharp
titleC#
          ExcelApplication xla = new ExcelApplication();
          Workbook wb = xla.Open(@"C:\MySpreadsheet.xlsx");
          Worksheet ws = wb.Worksheets[0];
          PivotTableLayout.LayoutOptionLayoutOptions layout = ws.PivotTables[0].PivotTableLayout.ReportLayout;
          ws.PivotTables[0].PivotTableLayout.ReportLayout = PivotTableLayout.LayoutOptionLayoutOptions.Tabular;
        
Code Block
vbnet
vbnet
titlevb.net
          Dim xla As New ExcelApplication()
          Dim wb As Workbook = xla.Open("C:\MySpreadsheet.xlsx")
          Dim ws As Worksheet = wb.Worksheets(0)
          Dim layout As PivotTableLayout.LayoutOptionLayoutOptions = ws.PivotTables(0).PivotTableLayout.ReportLayout
          ws.PivotTables(0).PivotTableLayout.ReportLayout = PivotTableLayout.LayoutOptionLayoutOptions.Tabular
        
Remarks

This property corresponds to the PivotTable layout options under PivotTable Layout on the Design tab. Together with the PivotTableSettings.ClassicLayout property this enables the ability to drag and drop fields in the PivotTable grid.

The default layout value of is Compact for PivotTables generated by ExcelWriter.

...