C# 操作excel单元格居中 | 您所在的位置:网站首页 › Excel居中对齐的简便操作 › C# 操作excel单元格居中 |
((Excel.Range)xlWorkSheet.Cells[3, 2]).HorizontalAlignment = Excel.XlVAlign.xlVAlignCenter; 设置第三行,第二列内容居中。 ((Excel.Range)xlWorkSheet.Cells[1, 2]).ColumnWidth = 15; 设置第一行第二列宽度为15 ((Excel.Range)xlWorkSheet.Cells[1, 1]).Font.Bold=true; 设置第一行第一列字体为粗体。
补充一句,因为 //range.HorizontalAlignment = Excel.Constants.xlCenter; //水平居中 //range.VerticalAlignment = Excel.Constants.xlCenter; //垂直居中 这种一次性设置整个EXCEL居中无法实现,所以在循环写入内容时使用语句: ((Excel.Range)xlWorkSheet.Cells[i, j]).HorizontalAlignment = Excel.XlVAlign.xlVAlignCenter; 才能实现整个EXCEL内容居中 |
CopyRight 2018-2019 实验室设备网 版权所有 |