diff --git a/ClosedXML/Excel/ConditionalFormats/IXLConditionalFormat.cs b/ClosedXML/Excel/ConditionalFormats/IXLConditionalFormat.cs index f0551fb..01aedba 100644 --- a/ClosedXML/Excel/ConditionalFormats/IXLConditionalFormat.cs +++ b/ClosedXML/Excel/ConditionalFormats/IXLConditionalFormat.cs @@ -139,6 +139,7 @@ Boolean ReverseIconOrder { get; } Boolean ShowIconOnly { get; } Boolean ShowBarOnly { get; } + Boolean StopIfTrue { get; } IXLRange Range { get; set; } XLDictionary Values { get; } @@ -150,6 +151,7 @@ Boolean Bottom { get; } Boolean Percent { get; } - IXLConditionalFormat StopIfTrue(bool value = true); + IXLConditionalFormat SetStopIfTrue(); + IXLConditionalFormat SetStopIfTrue(Boolean value); } } diff --git a/ClosedXML/Excel/ConditionalFormats/Save/XLCFBaseConverter.cs b/ClosedXML/Excel/ConditionalFormats/Save/XLCFBaseConverter.cs index 83acea3..5461406 100644 --- a/ClosedXML/Excel/ConditionalFormats/Save/XLCFBaseConverter.cs +++ b/ClosedXML/Excel/ConditionalFormats/Save/XLCFBaseConverter.cs @@ -11,7 +11,7 @@ { Type = cf.ConditionalFormatType.ToOpenXml(), Priority = priority, - StopIfTrue = OpenXmlHelper.GetBooleanValue(((XLConditionalFormat)cf).StopIfTrueInternal, false) + StopIfTrue = OpenXmlHelper.GetBooleanValue(cf.StopIfTrue, false) }; } } diff --git a/ClosedXML/Excel/ConditionalFormats/XLConditionalFormat.cs b/ClosedXML/Excel/ConditionalFormats/XLConditionalFormat.cs index 5023880..1e4cdb5 100644 --- a/ClosedXML/Excel/ConditionalFormats/XLConditionalFormat.cs +++ b/ClosedXML/Excel/ConditionalFormats/XLConditionalFormat.cs @@ -38,17 +38,17 @@ var yStyle = yy._style ?? yy.Range.Worksheet.Workbook.GetStyleById(yy._styleCacheId); return Equals(xStyle, yStyle) - && xx.CopyDefaultModify == yy.CopyDefaultModify + && xx.CopyDefaultModify == yy.CopyDefaultModify && xx.UpdatingStyle == yy.UpdatingStyle - && xx.ConditionalFormatType == yy.ConditionalFormatType - && xx.TimePeriod == yy.TimePeriod - && xx.IconSetStyle == yy.IconSetStyle - && xx.Operator == yy.Operator - && xx.Bottom == yy.Bottom - && xx.Percent == yy.Percent - && xx.ReverseIconOrder == yy.ReverseIconOrder - && xx.StopIfTrueInternal == yy.StopIfTrueInternal - && xx.ShowIconOnly == yy.ShowIconOnly + && xx.ConditionalFormatType == yy.ConditionalFormatType + && xx.TimePeriod == yy.TimePeriod + && xx.IconSetStyle == yy.IconSetStyle + && xx.Operator == yy.Operator + && xx.Bottom == yy.Bottom + && xx.Percent == yy.Percent + && xx.ReverseIconOrder == yy.ReverseIconOrder + && xx.StopIfTrue == yy.StopIfTrue + && xx.ShowIconOnly == yy.ShowIconOnly && xx.ShowBarOnly == yy.ShowBarOnly && _listComparer.Equals(xxValues, yyValues) && _listComparer.Equals(xxFormulas, yyFormulas) @@ -85,7 +85,7 @@ hashCode = (hashCode * 397) ^ xx.ReverseIconOrder.GetHashCode(); hashCode = (hashCode * 397) ^ xx.ShowIconOnly.GetHashCode(); hashCode = (hashCode * 397) ^ xx.ShowBarOnly.GetHashCode(); - hashCode = (hashCode * 397) ^ xx.StopIfTrueInternal.GetHashCode(); + hashCode = (hashCode * 397) ^ xx.StopIfTrue.GetHashCode(); return hashCode; } } @@ -136,7 +136,7 @@ ReverseIconOrder = conditionalFormat.ReverseIconOrder; ShowIconOnly = conditionalFormat.ShowIconOnly; ShowBarOnly = conditionalFormat.ShowBarOnly; - StopIfTrueInternal = OpenXmlHelper.GetBooleanValueAsBool(conditionalFormat.StopIfTrueInternal, true); + StopIfTrue = OpenXmlHelper.GetBooleanValueAsBool(conditionalFormat.StopIfTrue, true); } @@ -197,12 +197,16 @@ public Boolean ReverseIconOrder { get; set; } public Boolean ShowIconOnly { get; set; } public Boolean ShowBarOnly { get; set; } + public Boolean StopIfTrue { get; set; } - internal bool StopIfTrueInternal { get; set; } - - public IXLConditionalFormat StopIfTrue(bool value = true) + public IXLConditionalFormat SetStopIfTrue() { - StopIfTrueInternal = value; + return SetStopIfTrue(true); + } + + public IXLConditionalFormat SetStopIfTrue(bool value) + { + this.StopIfTrue = value; return this; } @@ -218,7 +222,7 @@ ReverseIconOrder = other.ReverseIconOrder; ShowIconOnly = other.ShowIconOnly; ShowBarOnly = other.ShowBarOnly; - StopIfTrueInternal = ((XLConditionalFormat)other).StopIfTrueInternal; + StopIfTrue = other.StopIfTrue; Values.Clear(); other.Values.ForEach(kp => Values.Add(kp.Key, new XLFormula(kp.Value))); diff --git a/ClosedXML/Excel/XLWorkbook_Load.cs b/ClosedXML/Excel/XLWorkbook_Load.cs index 29a27c1..821c8d1 100644 --- a/ClosedXML/Excel/XLWorkbook_Load.cs +++ b/ClosedXML/Excel/XLWorkbook_Load.cs @@ -2037,7 +2037,7 @@ { var conditionalFormat = new XLConditionalFormat(ws.Range(sor.Value)); - conditionalFormat.StopIfTrueInternal = OpenXmlHelper.GetBooleanValueAsBool(fr.StopIfTrue, false); + conditionalFormat.StopIfTrue = OpenXmlHelper.GetBooleanValueAsBool(fr.StopIfTrue, false); if (fr.FormatId != null) { diff --git a/ClosedXML_Examples/ConditionalFormatting/ConditionalFormatting.cs b/ClosedXML_Examples/ConditionalFormatting/ConditionalFormatting.cs index d845942..e1873c1 100644 --- a/ClosedXML_Examples/ConditionalFormatting/ConditionalFormatting.cs +++ b/ClosedXML_Examples/ConditionalFormatting/ConditionalFormatting.cs @@ -676,7 +676,7 @@ .CellBelow().SetValue(2) .CellBelow().SetValue(3); - ws.RangeUsed().AddConditionalFormat().StopIfTrue().WhenGreaterThan(5); + ws.RangeUsed().AddConditionalFormat().SetStopIfTrue().WhenGreaterThan(5); ws.RangeUsed().AddConditionalFormat().IconSet(XLIconSetStyle.ThreeTrafficLights2, true, true) .AddValue(XLCFIconSetOperator.EqualOrGreaterThan, "0", XLCFContentType.Number)