EPPlus 设置整个工作表的背景颜色
EPPlus Set background color of entire worksheet
使用 EPPlus,我了解到您可以设置单个单元格或一系列单元格的背景颜色,如下所示:
ws.Cells["A1:B1"].Style.Fill.PatternType = ExcelFillStyle.Solid;
ws.Cells["A1:B1"].Style.Fill.BackgroundColor.SetColor(Color.White);
有什么方法可以设置整个工作表的背景色吗?或者这只是设置非常广泛的单元格的情况?
例如我可以这样做:
ws.Cells["A1:AZ10000"].Style.Fill.PatternType = ExcelFillStyle.Solid;
ws.Cells["A1:AZ10000"].Style.Fill.BackgroundColor.SetColor(Color.White);
我不确定这样做是否存在性能问题?我用 "A1:ZZ100000" 试了一下,它就挂了。
不指定地址范围,直接使用单元格即可:
ws.Cells.Style.Fill.PatternType = ExcelFillStyle.Solid;
ws.Cells.Style.Fill.BackgroundColor.SetColor(Color.White);
测试了一下,不花时间。
更简单!
ws.SetBackgroundColor(Color.HotPink);
使用 EPPlus,我了解到您可以设置单个单元格或一系列单元格的背景颜色,如下所示:
ws.Cells["A1:B1"].Style.Fill.PatternType = ExcelFillStyle.Solid;
ws.Cells["A1:B1"].Style.Fill.BackgroundColor.SetColor(Color.White);
有什么方法可以设置整个工作表的背景色吗?或者这只是设置非常广泛的单元格的情况?
例如我可以这样做:
ws.Cells["A1:AZ10000"].Style.Fill.PatternType = ExcelFillStyle.Solid;
ws.Cells["A1:AZ10000"].Style.Fill.BackgroundColor.SetColor(Color.White);
我不确定这样做是否存在性能问题?我用 "A1:ZZ100000" 试了一下,它就挂了。
不指定地址范围,直接使用单元格即可:
ws.Cells.Style.Fill.PatternType = ExcelFillStyle.Solid;
ws.Cells.Style.Fill.BackgroundColor.SetColor(Color.White);
测试了一下,不花时间。
更简单!
ws.SetBackgroundColor(Color.HotPink);