Get Started
Usage API
More information

SetAlignHorizontal

SetAlignHorizontal(sAlignment) → { bool }

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

Parameters:

Name Type Description
sAlignment 'left' | 'right' | 'center' | 'justify'

The horizontal alignment that will be applied to the cell contents.

Returns:

Type
bool

Example

Copy code
builder.CreateFile("xlsx");
var oWorksheet = Api.GetActiveSheet();
oWorksheet.GetRange("A2").SetValue("2");
var oRange = oWorksheet.GetRange("A1:D5");
oRange.SetAlignHorizontal("center");
builder.SaveFile("xlsx", "SetAlignHorizontal.xlsx");
builder.CloseFile();

Resulting document