Skip to main content

SetTableStyleColumnStripes

Sets the setting which specifies whether the background color alternation for odd and even columns will be enabled for the pivot table.

Syntax

expression.SetTableStyleColumnStripes(show);

expression - A variable that represents a ApiPivotTable class.

Parameters

NameRequired/OptionalData typeDefaultDescription
showRequiredbooleanSpecifies whether the background color alternation for odd and even columns will be enabled for the pivot table.

Returns

This method doesn't return any data.

Example

Set table style column stripes of a pivot table in a spreadsheet.

// How to set table style column stripes of a table in a spreadsheet.

// Create a pivot table, add data to it then set its table style column stripes 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({
columns: ['Region', 'Style'],
});

pivotTable.AddDataField('Price');
pivotTable.SetTableStyleColumnStripes(true);

let pivotWorksheet = Api.GetActiveSheet();

pivotWorksheet.GetRange('A12').SetValue('Table Style Column Stripes');
pivotWorksheet.GetRange('B12').SetValue(pivotTable.GetTableStyleColumnStripes());