如果单元格中的值小于 0,是否可以应用自定义格式设置颜色为红色。
我知道如何通过为单个单元格设置颜色来做到这一点,但是我有 8 个包含很多单元格的报告,我只想在整个工作表上应用这个规则,所以我不必为每个单元格都这样做。
提前致谢。
最佳答案
在低于 12 版本的互操作中没有办法做到这一点。
我更改了 的版本interop.excel Excel 2010 到 14 及其使用
FormatCondition f = (FormatCondition)r.FormatConditions.Add(XlFormatConditionType.xlCellValue,
XlFormatConditionOperator.xlLess, 0, misValue, misValue,
misValue, misValue, misValue);
f.Font.Color = ColorTranslator.ToOle(Color.Red);
FormatCondition 属性(property)
关于C# 到 Excel - 自定义格式?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8447239/