using Microsoft.Office.Interop.Excel;
Range rng = worksheet.UsedRange;
//我发现下面的代码,但我没有找到引用ExcelAlignemt和excel我错过了这个需要的内容
rng.VerticalAlignment = ExcelAlignment.xlButtom; //or Excel.XlHAlign.xlHAlignLeft
答案 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;