Reputation: 1425
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
Reputation: 11
One should note that for vertical alignment, you should use :
XlVAlign.xlVAlignBottom/XlVAlign.xlVAlignTop
not
XlHAlign.xlHAlignLeft
Upvotes: 0
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