Skip to main content

SetCenterHorizontally

Sets whether the worksheet is centered horizontally on the page when printed.

Syntax​

expression.SetCenterHorizontally(bCenter);

expression - A variable that represents an ApiPageSetup class.

Parameters​

NameRequired/OptionalData typeDefaultDescription
bCenterRequiredbooleanSpecifies whether the worksheet is centered horizontally on the page.

Returns​

boolean

Example​

Center the printed content horizontally on the page in a spreadsheet.

// How do I center the worksheet between the left and right margins when printing in a spreadsheet?

// Make the printout horizontally centered on the page in a spreadsheet.

let worksheet = Api.GetActiveSheet();
let pageSetup = worksheet.GetPageSetup();
pageSetup.SetCenterHorizontally(true);