sagar
sagar

Reputation: 1425

How do i set VerticalAlignment to bottom for range?

using Microsoft.Office.Interop.Excel;
Range rng = worksheet.UsedRange;

// I found below code but I didn't found ref to both ExcelAlignemt and excel I i missing something which ref required for this

rng.VerticalAlignment = ExcelAlignment.xlButtom; //or Excel.XlHAlign.xlHAlignLeft

Upvotes: 5

Views: 9731

Answers (2)

Justin
Justin

Reputation: 11

One should note that for vertical alignment, you should use :

XlVAlign.xlVAlignBottom/XlVAlign.xlVAlignTop

not

XlHAlign.xlHAlignLeft

Upvotes: 0

opewix
opewix

Reputation: 5083

xlHAlignCenter is in Excel namespace:

worksheet.get_Range("A1", "A1").Style.HorizontalAlignment = Microsoft.Office.Interop.Excel.XlHAlign.xlHAlignCenter;

Now, with your code:

rng.Style.VerticalAlignment = Microsoft.Office.Interop.Excel.XlHAlign.xlHAlignLeft;

Upvotes: 8

Related Questions