C# 设置 Excel 单元格的方法
2018-07-20 来源:open-open
例如设置单元格颜色、添加或者删除sheet、重命名、行的添加删除等
[C#]代码
using Microsoft.Office.Core; using Microsoft.Office.Interop.Excel; using System.IO; using System.Reflection; Application app = new Application(); Workbooks wbks = app.Workbooks; _Workbook _wbk = wbks.Add(xxx); //Open an exist Excel file, please replace “xxx” with the excel file path. //Create a new Excel file, please replace “xxx” with “true”. //Note: there is only one worksheet in the excel file. Sheets shs = _wbk.Sheets; //Left side boder line _wsh.get_Range( _wsh.Cells[2, 1], _wsh.Cells[2, 2]) .Borders[XlBordersIndex.xlEdgeLeft].Weight = XlBorderWeight.xlThick;// //Right side border line _wsh.get_Range( _wsh.Cells[2, 1], _wsh.Cells[2, 2]) .Borders[XlBordersIndex.xlEdgeRight].Weight = XlBorderWeight.xlThick;// //Upside border line _wsh.get_Range( _wsh.Cells[2, 1], _wsh.Cells[2, 2]) .Borders[XlBordersIndex.xlEdgeTop].Weight = XlBorderWeight.xlThick;//下 //Downside border line _wsh.get_Range( _wsh.Cells[2, 1], _wsh.Cells[2, 2]) .Borders[XlBordersIndex.xlEdgeBottom].Weight = XlBorderWeight.xlThick;
标签: 代码
版权申明:本站文章部分自网络,如有侵权,请联系:west999com@outlook.com
特别注意:本站所有转载文章言论不代表本站观点!
本站所提供的图片等素材,版权归原作者所有,如需使用,请与原作者联系。
下一篇:C# 实现的 AES 加密算法
最新资讯
热门推荐