【发布时间】:2015-02-24 07:36:20
【问题描述】:
我需要将此精确的条件格式转换为 c#。
我尝试使用以下代码。但由于 C5 不在范围内,因此无法正常工作。
Range extendedRange = activeWorksheet.get_Range("D5", oOpt).get_Resize(129, 3);
FormatConditions fcs = extendedRange.FormatConditions;
FormatCondition fc = (FormatCondition)fcs.Add(XlFormatConditionType.xlCellValue, XlFormatConditionOperator.xlGreater, "=C5", oOpt, oOpt,
oOpt, oOpt, oOpt);
Interior interior = fc.Interior;
interior.Color = ColorTranslator.ToOle(Color.Red);
我正在使用 interop.excel 12.0.0.0 。有人可以帮我解决这个问题吗?提前致谢
编辑: 我希望这是一个真实的参考。所以,在 excel 条件格式中显示的正是我想要的。但是,当我尝试使用我的代码时,公式变为 D5 而不是 C5。我认为这可能是因为我的范围内没有 C5 单元格。我正在使用 Visual Studio 2008 SP1。
【问题讨论】:
标签: c# excel conditional-formatting