diff --git a/ClosedXML/Excel/ConditionalFormats/IXLConditionalFormat.cs b/ClosedXML/Excel/ConditionalFormats/IXLConditionalFormat.cs index c04d7a1..b47d0e7 100644 --- a/ClosedXML/Excel/ConditionalFormats/IXLConditionalFormat.cs +++ b/ClosedXML/Excel/ConditionalFormats/IXLConditionalFormat.cs @@ -119,7 +119,7 @@ Boolean Bottom { get; } Boolean Percent { get; } - IXLConditionalFormat StopIfTrue(bool value); + IXLConditionalFormat StopIfTrue(bool value = true); } } diff --git a/ClosedXML/Excel/ConditionalFormats/Save/XLCFConverters.cs b/ClosedXML/Excel/ConditionalFormats/Save/XLCFConverters.cs index 28fb37f..2186baf 100644 --- a/ClosedXML/Excel/ConditionalFormats/Save/XLCFConverters.cs +++ b/ClosedXML/Excel/ConditionalFormats/Save/XLCFConverters.cs @@ -11,26 +11,25 @@ private static readonly Dictionary Converters; static XLCFConverters() { - Converters = new Dictionary - { - {XLConditionalFormatType.ColorScale, new XLCFColorScaleConverter()}, - {XLConditionalFormatType.StartsWith, new XLCFStartsWithConverter()}, - {XLConditionalFormatType.EndsWith, new XLCFEndsWithConverter()}, - {XLConditionalFormatType.IsBlank, new XLCFIsBlankConverter()}, - {XLConditionalFormatType.NotBlank, new XLCFNotBlankConverter()}, - {XLConditionalFormatType.IsError, new XLCFIsErrorConverter()}, - {XLConditionalFormatType.NotError, new XLCFNotErrorConverter()}, - {XLConditionalFormatType.ContainsText, new XLCFContainsConverter()}, - {XLConditionalFormatType.NotContainsText, new XLCFNotContainsConverter()}, - {XLConditionalFormatType.CellIs, new XLCFCellIsConverter()}, - {XLConditionalFormatType.IsUnique, new XLCFUniqueConverter()}, - {XLConditionalFormatType.IsDuplicate, new XLCFUniqueConverter()}, - {XLConditionalFormatType.Expression, new XLCFCellIsConverter()}, - {XLConditionalFormatType.Top10, new XLCFTopConverter()}, - {XLConditionalFormatType.DataBar, new XLCFDataBarConverter()}, - {XLConditionalFormatType.IconSet, new XLCFIconSetConverter()} - }; + Converters = new Dictionary(); + Converters.Add(XLConditionalFormatType.ColorScale, new XLCFColorScaleConverter()); + Converters.Add(XLConditionalFormatType.StartsWith, new XLCFStartsWithConverter()); + Converters.Add(XLConditionalFormatType.EndsWith, new XLCFEndsWithConverter()); + Converters.Add(XLConditionalFormatType.IsBlank, new XLCFIsBlankConverter()); + Converters.Add(XLConditionalFormatType.NotBlank, new XLCFNotBlankConverter()); + Converters.Add(XLConditionalFormatType.IsError, new XLCFIsErrorConverter()); + Converters.Add(XLConditionalFormatType.NotError, new XLCFNotErrorConverter()); + Converters.Add(XLConditionalFormatType.ContainsText, new XLCFContainsConverter()); + Converters.Add(XLConditionalFormatType.NotContainsText, new XLCFNotContainsConverter()); + Converters.Add(XLConditionalFormatType.CellIs, new XLCFCellIsConverter()); + Converters.Add(XLConditionalFormatType.IsUnique, new XLCFUniqueConverter()); + Converters.Add(XLConditionalFormatType.IsDuplicate, new XLCFUniqueConverter()); + Converters.Add(XLConditionalFormatType.Expression, new XLCFCellIsConverter()); + Converters.Add(XLConditionalFormatType.Top10, new XLCFTopConverter()); + Converters.Add(XLConditionalFormatType.DataBar, new XLCFDataBarConverter()); + Converters.Add(XLConditionalFormatType.IconSet, new XLCFIconSetConverter()); } + public static ConditionalFormattingRule Convert(IXLConditionalFormat conditionalFormat, Int32 priority, XLWorkbook.SaveContext context) { return Converters[conditionalFormat.ConditionalFormatType].Convert(conditionalFormat, priority, context); diff --git a/ClosedXML/Excel/ConditionalFormats/XLConditionalFormat.cs b/ClosedXML/Excel/ConditionalFormats/XLConditionalFormat.cs index 692d4a8..03aa8ca 100644 --- a/ClosedXML/Excel/ConditionalFormats/XLConditionalFormat.cs +++ b/ClosedXML/Excel/ConditionalFormats/XLConditionalFormat.cs @@ -103,7 +103,7 @@ internal bool StopIfTrueInternal { get; set; } - public IXLConditionalFormat StopIfTrue(bool value) + public IXLConditionalFormat StopIfTrue(bool value = true) { StopIfTrueInternal = value; return this; @@ -121,7 +121,7 @@ ReverseIconOrder = other.ReverseIconOrder; ShowIconOnly = other.ShowIconOnly; ShowBarOnly = other.ShowBarOnly; - StopIfTrueInternal = OpenXmlHelper.GetBooleanValueAsBool(((XLConditionalFormat)other).StopIfTrueInternal, true); + StopIfTrueInternal = ((XLConditionalFormat)other).StopIfTrueInternal; 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 f2080c5..008f99a 100644 --- a/ClosedXML/Excel/XLWorkbook_Load.cs +++ b/ClosedXML/Excel/XLWorkbook_Load.cs @@ -1839,7 +1839,7 @@ { var conditionalFormat = new XLConditionalFormat(ws.Range(sor.Value)); - conditionalFormat.StopIfTrueInternal = OpenXmlHelper.GetBooleanValueAsBool(fr.StopIfTrue, false); + conditionalFormat.StopIfTrueInternal = fr.StopIfTrue; if (fr.FormatId != null) {