Excel Cell样式

时间:2014-07-30 17:31:22

标签: c# .net excel

我希望在Excel工作表的单元格中获得完整的样式,例如合并,着色和字体大小调整。现在我正在使用Microsoft.Office.Interop.Excel库,但我很困惑使用它。

这是我现在使用的代码

            Microsoft.Office.Interop.Excel.Application excelApp = new Microsoft.Office.Interop.Excel.Application();
            excelApp.Application.Workbooks.Add(Type.Missing);
            excelApp.Columns.ColumnWidth = 20;
            excelApp.Cells[7, 1].Borders[Microsoft.Office.Interop.Excel.XlBordersIndex.xlEdgeLeft].Weight = 1d;

我也想合并单元格,样式边框和着色。有人可以帮助一个示例代码吗?

1 个答案:

答案 0 :(得分:0)

感谢谁试图解决我的问题,我找到了解决我自己的问题的解决方案

            // what is here merging    
            excelApp.Range[excelApp.Cells[2, 2], excelApp.Cells[2, 5]].Merge();

            // what is here boarder
            excelApp.Range[excelApp.Cells[1, 1], excelApp.Cells[1, 2]].Borders[Microsoft.Office.Interop.Excel.XlBordersIndex.xlEdgeLeft].Weight = 3d;