跳到主要内容

SetAlignHorizontal

Sets the horizontal alignment of the text in the current cell range.

Syntax

expression.SetAlignHorizontal(sAlignment);

expression - A variable that represents a ApiRange class.

Parameters

NameRequired/OptionalData typeDefaultDescription
sAlignmentRequired'left' | 'right' | 'center' | 'justify'The horizontal alignment that will be applied to the cell contents.

Returns

boolean

Example

This example sets the horizontal alignment of the text in the cell range.

let worksheet = Api.GetActiveSheet();
worksheet.GetRange("A2").SetValue("2");
let range = worksheet.GetRange("A1:D5");
range.SetAlignHorizontal("center");