Get Started
Documentation

SetAlignHorizontal

SetAlignHorizontal(value)

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

Parameters:

Name Type Description
value "left" | "right" | "center" | "justify" The parameters will define the justification type that will be applied to the cell contents.

Example

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

Resulting document