我使用这个包:ExcelPackage,尽管我不知道如何设置单元格的背景色。我试着使用这个:
ws.Cells["A1"].Style.Fill.PatternType = OfficeOpenXml.Style.ExcelFillStyle.Solid;
但是它显示没有找到这些属性。
听起来我应该使用类似于下面这样的东西:
worksheet.Cell(5, columnIndex + 1).Style = "background-color: red";
但我不确定它是如何工作的,我也找不到它的教程。请帮帮忙。
发布于 2013-06-18 06:05:46
尝试以下内容(取自提供的EPPlus示例文件):
using (var range = worksheet.Cells[1, 1, 1, 5])
{
range.Style.Fill.PatternType = ExcelFillStyle.Solid;
range.Style.Fill.BackgroundColor.SetColor(Color.DarkBlue);
}
发布于 2018-03-05 15:04:14
对于ExcelPackage
workSheet.Cells["A1:B1"].Style.Fill.PatternType = OfficeOpenXml.Style.ExcelFillStyle.LightTrellis;
workSheet.Cells["A1:B1"].Style.Fill.BackgroundColor.SetColor(System.Drawing.Color.LightSeaGreen);
var allCells = workSheet.Cells["A1:B1"];
var cellFont = allCells.Style.Font;
https://stackoverflow.com/questions/17156118
复制相似问题