EPPlus设置整个工作表的背景色

Jac*_*ues 1 c# epplus

使用EPPlus,我知道您可以如下设置单个单元格或一系列单元格的背景色:

ws.Cells["A1:B1"].Style.Fill.PatternType = ExcelFillStyle.Solid;
ws.Cells["A1:B1"].Style.Fill.BackgroundColor.SetColor(Color.White);  
Run Code Online (Sandbox Code Playgroud)

有什么方法可以设置整个工作表的背景色吗?还是这只是设置范围很广的单元格的一种情况?

因此,例如,我可以做:

ws.Cells["A1:AZ10000"].Style.Fill.PatternType = ExcelFillStyle.Solid;
ws.Cells["A1:AZ10000"].Style.Fill.BackgroundColor.SetColor(Color.White);
Run Code Online (Sandbox Code Playgroud)

我不确定这样做是否有性能问题?我用“ A1:ZZ100000”进行了尝试,它只是挂了。

Yah*_*ein 6

无需指定地址范围即可直接使用单元格:

ws.Cells.Style.Fill.PatternType = ExcelFillStyle.Solid;
ws.Cells.Style.Fill.BackgroundColor.SetColor(Color.White);
Run Code Online (Sandbox Code Playgroud)

经过测试,不需要任何时间。