使用 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);
测试了一下,不花时间。
关于c# - EPPlus 设置整个工作表的背景颜色,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47773663/