Skip to main content

SetRowAxisLayout

Sets the way the specified pivot table items appear — in table format or in outline format.

Syntax

expression.SetRowAxisLayout(type, compact);

expression - A variable that represents a ApiPivotTable class.

Parameters

NameRequired/OptionalData typeDefaultDescription
typeRequiredPivotLayoutTypeThe layout type of the pivot table report.
compactRequiredbooleanSpecifies whether the pivot table items will be displayed in the compact form.

Returns

This method doesn't return any data.

Example

Choose how row fields are arranged in a pivot table in a spreadsheet.

// How do I switch a pivot table to tabular or outline layout in a spreadsheet?

// Change the visual structure of row categories to match a preferred report format in a spreadsheet.

let worksheet = Api.GetActiveSheet();

worksheet.GetRange('B1').SetValue('Region');
worksheet.GetRange('C1').SetValue('Style');
worksheet.GetRange('D1').SetValue('Price');

worksheet.GetRange('B2').SetValue('East');
worksheet.GetRange('B3').SetValue('West');
worksheet.GetRange('B4').SetValue('East');
worksheet.GetRange('B5').SetValue('West');

worksheet.GetRange('C2').SetValue('Fancy');
worksheet.GetRange('C3').SetValue('Fancy');
worksheet.GetRange('C4').SetValue('Tee');
worksheet.GetRange('C5').SetValue('Tee');

worksheet.GetRange('D2').SetValue(42.5);
worksheet.GetRange('D3').SetValue(35.2);
worksheet.GetRange('D4').SetValue(12.3);
worksheet.GetRange('D5').SetValue(24.8);

let dataRef = Api.GetRange("'Sheet1'!$B$1:$D$5");
let pivotTable = Api.InsertPivotNewWorksheet(dataRef);

pivotTable.AddFields({
rows: ['Region', 'Style'],
});

pivotTable.AddDataField('Price');

pivotTable.SetRowAxisLayout('Tabular', false);