0

我有一个带有动态值的模板。我想在使用 SoftArtisians Excel Writer 时添加 3 个色阶条件格式列。此条件格式代码添加条件以提供单元格颜色值。我想添加类似类型的代码来明智地添加 3 色标格式化规则列。

ConditionalFormat cf = wb.CreateConditionalFormat(); //Create a conditional format
                                                    Condition condRed = cf.CreateCondition(Condition.Comparison.FormulaEvaluation, "=IF( " + Convert.ToInt32(cell.Value) + " < 0,1,0)");
                                                    Condition condGreen = cf.CreateCondition(Condition.Comparison.FormulaEvaluation, "=IF( " + Convert.ToInt32(cell.Value) + " > 0,1,0)");

                                                    condRed.Style.Font.Color = wb.Palette.GetClosestColor(255, 0, 0);
                                                    condGreen.Style.Font.Color = wb.Palette.GetClosestColor(0, 153, 0);
                                                    Range range = wb.CreateRange("=" + "'" + wb.Worksheets[0].Name + "'!" + wb.Worksheets[0].Cells[currentRow, currentCol].Name);
                                                    range.SetConditionalFormat(cf);

谢谢

4

0 回答 0