我需要将输出excel文件中的错误单元格标记为红色。如果在原始文档中这些单元格没有填充,则一切都很好,颜色为红色。但如果细胞已经充满了蓝色(或某种类型),在输出中它会变成粉红色,但不是红色! 这是我的代码:
var cell = worksheet.Cells[row, column];
cell.Reset();
cell.Value = string.Format("{0} Error:{1}", cell.Value, errortext);
cell.Style.Fill.BackgroundColor.SetColor(Color.Empty);
cell.Style.Fill.PatternType = ExcelFillStyle.Solid;
cell.Style.Fill.BackgroundColor.SetColor(Color.Red);
cell.Style.Fill.BackgroundColor.SetColor(Color.FromArgb(255, 0, 0));
这应该是它的样子:
如果原始填充为蓝色,则为此:
非常感谢任何帮助。
答案 0 :(得分:1)
cell.Style.Fill.BackgroundColor.Tint = 0;
有帮助。