NativeExcel for .Net Developer's Reference

IRange.HorizontalAlignment Property

Gets or sets the horizontal alignment for the specified range.

[Visual Basic]
PropertyHorizontalAlignmentAsXlHAlign
[C#]
XlHAlignHorizontalAlignment{get;set;}
[C++]
__propertyXlHAlignget_HorizontalAlignment();
__propertyvoidset_HorizontalAlignment(XlHAlign);
[JScript]
functiongetHorizontalAlignment():XlHAlign
functionsetHorizontalAlignment(XlHAlign);

Property Value

One of the XlHAlign values.

Example

This example left aligns the range A1:A5 on sheet one.

[C#]
 book.Worksheets[1].Range["A1:A5"].HorizontalAlignment = XlHAlign.xlHAlignLeft;
[VisualBasic]
 book.Worksheets(1).Range("A1:A5").HorizontalAlignment = XlHAlign.xlHAlignLeft
[C++]
 book->Worksheets->Item[1]->Range->Item[S"A1:A5"]->HorizontalAlignment = XlHAlign::xlHAlignLeft;

See Also

IRange Interface | NativeExcel Namespace | XlHAlign Enumeration | VerticalAlignment Property