diff --git a/ClosedXML/Excel/XLWorkbook_Save.cs b/ClosedXML/Excel/XLWorkbook_Save.cs index 0bfa65c..bfce7b1 100644 --- a/ClosedXML/Excel/XLWorkbook_Save.cs +++ b/ClosedXML/Excel/XLWorkbook_Save.cs @@ -4038,7 +4038,7 @@ worksheetPart.Worksheet.RemoveAllChildren(); var previousElement = cm.GetPreviousElementFor(XLWSContentManager.XLWSContents.ConditionalFormatting); - var priority = 0; + var priority = 1; // priority is 1 origin in Microsoft Excel foreach (var cfGroup in xlWorksheet.ConditionalFormats .GroupBy( c => c.Range.RangeAddress.ToStringRelative(false), @@ -4047,8 +4047,6 @@ ) ) { - - priority++; var conditionalFormatting = new ConditionalFormatting { SequenceOfReferences = @@ -4057,6 +4055,7 @@ foreach(var cf in cfGroup.CfList) { conditionalFormatting.Append(XLCFConverters.Convert(cf, priority, context)); + priority++; } worksheetPart.Worksheet.InsertAfter(conditionalFormatting, previousElement); previousElement = conditionalFormatting;