我当前正在使用Microsoft.Office.Core;并使用Excel = Microsoft.Office.Interop.Excel;将数据从Windows窗体导出到excel,将数据从Windows窗体c#导出到excel
是否有可能在选定的单元格上添加边框 How i need it to be
答案 0 :(得分:1)
当然,这是我为同一件事制作的一个函数
/// <summary>
/// Puts a border around range
/// </summary>
/// <param name="ws">Excel worksheet</param>
/// <param name="r1">First Row</param>
/// <param name="c1">First Column</param>
/// <param name="r2">Last Row</param>
/// <param name="c2">Last Column</param>
/// <param name="weight">Border Brush Weight</param>
public void BorderRange(Worksheet ws, int r1, int c1, int r2, int c2, XlBorderWeight weight = XlBorderWeight.xlThin)
{
Range r = ws.Range[ws.Cells[r1, c1], ws.Cells[r2, c2]];
r.BorderAround2(Microsoft.Office.Interop.Excel.XlLineStyle.xlContinuous, weight);
}
您需要多次调用它才能使边界围绕所需的范围。