Skip to main content

How to: Change the PivotTable Layout

  • 3 minutes to read

To change the layout form of a PivotTable report, pass the appropriate PivotReportLayout enumeration member to the PivotLayout.SetReportLayout method.

The table below describes the available report layouts and lists additional options that can be set for each layout form.

Layout Form

Description

Additional Layout Options

Compact Form

(PivotReportLayout.Compact)

This is the default layout for a newly created PivotTable report. This layout enables you to keep your report as narrow as possible.

It displays items from different row fields in a single column and subsidiary row field items are shown indented to the left.

SpreadsheetPivotTable_CompactReportLayout

Outline Form

(PivotReportLayout.Outline)

This layout displays each row field in its own column. Subsidiary row field items begin one row below the parent field item.

SpreadsheetPivotTable_OutlineReportLayout

Tabular Form

(PivotReportLayout.Tabular)

This layout displays each row field in its own column. Subsidiary row field items begin on the same row.

Subtotals for items in the outer row fields are always shown at the bottom.

SpreadsheetPivotTable_TabularReportLayout

The following code example shows how to change the default PivotTable layout to outline form.

View Example

Worksheet worksheet = workbook.Worksheets["Report1"];
workbook.Worksheets.ActiveWorksheet = worksheet;

// Access the pivot table by its name in the collection.
PivotTable pivotTable = worksheet.PivotTables["PivotTable1"];
// Display the pivot table in the outline form.
pivotTable.Layout.SetReportLayout(PivotReportLayout.Outline);

Note

Besides changing the layout of the entire pivot table, you can also change the layout of a specific field in the report. To do this, use the corresponding properties of the PivotFieldLayout object, which can be accessed using the field’s PivotField.Layout property.