使用epplus c#设置Excel工作表单元格的自定义BackgroundColor
问题:
我正在使用EEPlus。
我坚持在我的Excel表格中应用hex颜色代码,例如#B7DEE8 。 
我得到了以下(工作)代码:
 ws.Cells["A1:B1"].Style.Fill.PatternType = ExcelFillStyle.Solid; ws.Cells["A1:B1"].Style.Fill.BackgroundColor.SetColor(Color.Gray); 
但是我需要如下的东西:
 ws.Cells["A1:B1"].Style.Fill.BackgroundColor.SetColor("#B7DEE8"); 
所以我的问题是:是否有可能使用hex颜色代码与EEPlus? 如果是这样,我该怎么做?
尝试这个
 Color colFromHex = System.Drawing.ColorTranslator.FromHtml("#B7DEE8"); ws.Cells["A1:B1"].Style.Fill.PatternType = ExcelFillStyle.Solid; ws.Cells["A1:B1"].Style.Fill.BackgroundColor.SetColor(colFromHex); 
这很好。
 Dim objExcel As New ExcelPackage Dim Sheet As ExcelWorksheet = objExcel.Workbook.Worksheets.Add("SheetName") Sheet.Cells["A1"].Style.Fill.PatternType = Style.ExcelFillStyle.Solid Sheet.Cells["A1"].Style.Fill.BackgroundColor.SetColor(Color.FromArgb(170, 170, 170))