var valuesC = this.Charges.Where(x => x.Type == PropertyType.Charge).ToList();
foreach(var valueCharge in valuesC)
{
var column = Sheet.Column(valueCharge.Id);
foreach(var cell in column.Cells())
{
cell.AddConditionalFormat().WhenIsTrue($"ISNUMBER(${cell.Address})=FALSE").Fill.SetBackgroundColor(XLColor.Red);
}
}
对大约 30 列执行的此操作非常慢,而且行数很少,有没有办法提高 ClosedXML 中此代码的性能? 12排大约需要2-3分钟。有什么我忽略的吗?
不要逐个单元格应用条件格式,而是在尽可能大的范围内应用条件格式。基本上,就像在 Excel 中一样,这可能是选择整个列并为每列应用一次条件格式。