我需要知道如何在excel中为基于单个单元格的for循环中的标题创建边框。以下是我要导出到excel的代码
witadmin.exe importcommonprocessconfig /collection:http://SERVERNAME:8080/tfs/DefaultCollection
/p:PROJECTNAME /f:.\processconfig.xml
答案 0 :(得分:1)
尝试使用Microsoft.Office.Interop.Excel: How to Apply a border to ONE CELL中的示例,例如:
Microsoft.Office.Interop.Excel.Range range = sheet.UsedRange;
Microsoft.Office.Interop.Excel.Range cell = range.Cells[1][1];
Microsoft.Office.Interop.Excel.Borders border = cell.Borders;
border[XlBordersIndex.xlEdgeLeft].LineStyle =
Microsoft.Office.Interop.Excel.XlLineStyle.xlContinuous;
border[XlBordersIndex.xlEdgeTop].LineStyle =
Microsoft.Office.Interop.Excel.XlLineStyle.xlContinuous;
border[XlBordersIndex.xlEdgeBottom].LineStyle =
Microsoft.Office.Interop.Excel.XlLineStyle.xlContinuous;
border[XlBordersIndex.xlEdgeRight].LineStyle =
Microsoft.Office.Interop.Excel.XlLineStyle.xlContinuous;
答案 1 :(得分:0)
这就是我做的事情
public void MarkBorder(string fromColName, string toColName)
{
string colName = fromColName + ":" + toColName;
CurrentWorksheet.Range[colName].BorderAround();
}
其中CurrentWorksheet定义为
public Worksheet CurrentWorksheet { get; set; }