回复 7楼unity的帖子
我测试的2015V3版本,使用该接口的方法如下。
假设值大于0的时候,单元格的颜色是红色,设置代码如下:- C1.C1Excel.XLSheet sheet = c1XLBook1.Sheets[0];
- XLConditionalFormatting xl = new XLConditionalFormatting();
- XLConditionalFormattingRule rule = new XLConditionalFormattingRule();
- XLPatternFormatting pattern = new XLPatternFormatting();
- pattern.BackColor = Color.Red;
- rule.Pattern = pattern;
- rule.Operator = XLConditionalFormattingOperator.GreaterThan;
- // Adding FirstFormula for the condition
- rule.FirstFormula = "0";
- rule.Parameter = 0;
- xl.Rules.Add(rule);
- xl.Ranges.Add(new XLRange(1, 1));
- sheet[1, 1].Value = 3;
- sheet.ConditionalFormattings.Add(xl);
复制代码 |