我正在将radgridview
导出到excel
。我的问题是如何在一个单元格上添加一个边框顶部...我真的很新,所以请耐心等待...
我已尝试使用此代码.Borders[Excel.XlBordersIndex.xlEdgeTop].Weight = 1d;
但仍无法在excel单元格上执行bordertop
.....
提前感谢。
foreach (GridViewSummaryRowInfo item in gridviewID.MasterView.SummaryRows)
{
objexcelapp.Cells[lastRow + 3, 4] = item.Cells[item.Index + 4].Value.ToString();
objexcelapp.Cells[lastRow + 3, 5] = item.Cells[item.Index + 5].Value.ToString();
objexcelapp.Cells[lastRow + 3, 4].Font.Bold = true;
objexcelapp.Cells[lastRow + 3, 5].Font.Bold = true;
}
答案 0 :(得分:0)
这个对我有用
Excel.Range range = sheet.UsedRange;
Excel.Range cell = range.Cells[1][1];
Excel.Borders border = cell.Borders;
border[XlBordersIndex.xlEdgeLeft].LineStyle =
Excel.XlLineStyle.xlContinuous;
border[XlBordersIndex.xlEdgeTop].LineStyle =
Excel.XlLineStyle.xlContinuous;
border[XlBordersIndex.xlEdgeBottom].LineStyle =
Excel.XlLineStyle.xlContinuous;
border[XlBordersIndex.xlEdgeRight].LineStyle =
Microsoft.Office.Interop.Excel.XlLineStyle.xlContinuous;