【发布时间】:2012-08-08 06:03:26
【问题描述】:
我正在尝试使用 C# 和以下代码添加条件格式。
Microsoft.Office.Interop.Excel.FormatCondition formatConditionObj = null;
formatConditionObj = (Microsoft.Office.Interop.Excel.FormatCondition)myRange
.FormatConditions.Add(Excel.XlFormatConditionType.xlExpression,
Type.Missing, true, Type.Missing, Type.Missing, Type.Missing,
Type.Missing, Type.Missing);
formatConditionObj.Interior.ColorIndex = 5;
我动态地更改应用这些格式的范围
formatConditionObj.ModifyAppliesToRange(NewRange);
现在我想删除这种应用的格式如何实现。
formatConditionObj.Delete();
这对我不起作用。这不会删除应用它的所有单元格的格式。仅删除最后的单元格格式。
我也尝试过使用
formatConditionObj.AppliesTo.Delete();
但它会删除也应用于该单元格的其他 ConditionalFormats。
注意:某些格式已应用于应用此条件格式的单元格,例如某些填充颜色。甚至还有一些其他条件格式应用于某些单元格。我只想删除这个特定的 ConditionalFormat(formatConditionObj)。
谁能帮帮我。
【问题讨论】:
标签: c# excel vsto conditional-formatting