如何将VerticalAlignment设置为范围的底部?

时间:2012-09-13 08:06:05

标签: c# excel

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

//我发现下面的代码,但我没有找到引用ExcelAlignemt和excel我错过了这个需要的内容

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

1 个答案:

答案 0 :(得分:5)

xlHAlignCenter位于Excel命名空间中:

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

现在,使用您的代码:

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