Syncfusion.XlsIO.Base
Example 


Syncfusion.XlsIO Namespace > IRange Interface : HorizontalAlignment Property

HorizontalAlignment Property (IRange)

Gets or sets the horizontal alignment for the specified object.
Syntax
'Declaration
 
Property HorizontalAlignment As ExcelHAlign
'Usage
 
Dim instance As IRange
Dim value As ExcelHAlign
 
instance.HorizontalAlignment = value
 
value = instance.HorizontalAlignment
ExcelHAlign HorizontalAlignment {get; set;}
Example
By default ExcelHAlign.HAlignGeneral is set to cells. Here for example, we set ExcelHAlign.HAlignRight to align the cell contents to right.
using Syncfusion.XlsIO;
            
class Program
{
    static void Main()
    {
        using (ExcelEngine excelEngine = new ExcelEngine())
        {
            IApplication application = excelEngine.Excel;
            application.DefaultVersion = ExcelVersion.Excel2013;
            IWorkbook workbook = application.Workbooks.Create(1);
            IWorksheet worksheet = workbook.Worksheets[0];
            
            //Set text
            worksheet["A1"].Text = "Test";
            
            //Set alignment
            worksheet["A1"].HorizontalAlignment = ExcelHAlign.HAlignRight;
            
            //Set row height
            worksheet["A1"].RowHeight = 30;
            
            //Save and dispose
            workbook.SaveAs("CellFormats.xlsx");
            workbook.Close(); 
        }
    }
}
AssemblyVersion

Syncfusion.XlsIO.Base: 16.4460.0.40

See Also