- 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;
- //该片段来自于http://www.codesnippet.cn/detail/030920135563.html
来源: http://www.codesnippet.cn/detail/030920135563.html