我尝试在范围或单元格周围设置边框,但似乎我被卡住了。 我已经阅读了几乎所有主题,并没有找到解决方案......
OfficeOpenXml.ExcelRange Rng = workSheet.Range[workSheet.Cells[1, 1], workSheet.Cells[2, 2]];
Rng.Style.Border.BorderAround(OfficeOpenXml.Style.ExcelBorderStyle.Thin);
workSheet.Cells[1,1].BorderAround2(OfficeOpenXml.Style.ExcelBorderStyle.Thin);
两种解决方案都不起作用。
答案 0 :(得分:1)
using OfficeOpenXml;
using OfficeOpenXml.Style;
//...
using (var range = workSheet.Cells[1, 1, 2, 2])
{
range.Style.Border.BorderAround(ExcelBorderStyle.Thin);
}
答案 1 :(得分:-1)
另一种选择,示例代码:
worksheet.Cells["D16:AH23"].Style.Border.Bottom.Style = ExcelBorderStyle.Thin;
worksheet.Cells["D16:AH23"].Style.Border.Top.Style =ExcelBorderStyle.Thin;
worksheet.Cells["D16:AH23"].Style.Border.Left.Style = ExcelBorderStyle.Thin;
worksheet.Cells["D16:AH23"].Style.Border.Right.Style = ExcelBorderStyle.Thin;