如何设置颜色或背景" excelpackage"

问题描述:

我用这个包: ExcelPackage 虽然我无法弄清楚如何设置单元格的背景颜色。我试图用这样的:

I use this package: ExcelPackage though I can't figure out how to set the background color for the cell. I tried to use this:

ws.Cells["A1"].Style.Fill.PatternType = OfficeOpenXml.Style.ExcelFillStyle.Solid;



但它显示的属性都没有找到。

But it shows that the properties are not found.

声音我应该使用类似这样的:

Sounds like I should use something similar to this:

worksheet.Cell(5, columnIndex + 1).Style = "background-color: red";



但我不知道它是如何工作,我无法找到的教程吧。请帮忙

But I am not sure how it works and I couldn't find the tutorial for it. Please help.

尝试沿着这些路线的东西(从的 EPPlus 提供的示例文件):

Try something along these lines (Taken from the EPPlus sample files provided):

using (var range = worksheet.Cells[1, 1, 1, 5]) 
    {
        range.Style.Fill.PatternType = ExcelFillStyle.Solid;
        range.Style.Fill.BackgroundColor.SetColor(Color.DarkBlue);
    }