Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
using Microsoft.Office.Interop.Excel; Range rng = worksheet.UsedRange;
// 我找到了下面的代码,但我没有找到 ExcelAlignemt 和 excel 的引用我错过了一些需要这个引用的东西
rng.VerticalAlignment = ExcelAlignment.xlButtom; //or Excel.XlHAlign.xlHAlignLeft
xlHAlignCenter 位于 Excel 命名空间中:
worksheet.get_Range("A1", "A1").Style.HorizontalAlignment = Microsoft.Office.Interop.Excel.XlHAlign.xlHAlignCenter;
现在,使用您的代码:
rng.Style.VerticalAlignment = Microsoft.Office.Interop.Excel.XlHAlign.xlHAlignLeft;