diff --git a/ClosedXML/Excel/Cells/XLCell.cs b/ClosedXML/Excel/Cells/XLCell.cs index 46dd03c..8ce4c66 100644 --- a/ClosedXML/Excel/Cells/XLCell.cs +++ b/ClosedXML/Excel/Cells/XLCell.cs @@ -1131,10 +1131,10 @@ if (SettingHyperlink) return; - if (GetStyleForRead().Font.FontColor.Equals(_worksheet.Style.Font.FontColor)) + if (GetStyleForRead().Font.FontColor.Equals(_worksheet.StyleValue.Font.FontColor)) Style.Font.FontColor = XLColor.FromTheme(XLThemeColor.Hyperlink); - if (GetStyleForRead().Font.Underline == _worksheet.Style.Font.Underline) + if (GetStyleForRead().Font.Underline == _worksheet.StyleValue.Font.Underline) Style.Font.Underline = XLFontUnderlineValues.Single; } } @@ -2165,7 +2165,7 @@ { CopyValuesFrom(otherCell); - Style = otherCell.Style; + InnerStyle = otherCell.InnerStyle; if (copyDataValidations) { diff --git a/ClosedXML/Excel/Columns/XLColumn.cs b/ClosedXML/Excel/Columns/XLColumn.cs index b499b65..c660ae5 100644 --- a/ClosedXML/Excel/Columns/XLColumn.cs +++ b/ClosedXML/Excel/Columns/XLColumn.cs @@ -291,9 +291,9 @@ foreach (XLCell c in Column(startRow, endRow).CellsUsed()) { if (c.IsMerged()) continue; - + var cellStyle = c.Style; Double thisWidthMax = 0; - Int32 textRotation = c.Style.Alignment.TextRotation; + Int32 textRotation = c.StyleValue.Alignment.TextRotation; if (c.HasRichText || textRotation != 0 || c.InnerText.Contains(Environment.NewLine)) { var kpList = new List>(); @@ -326,7 +326,7 @@ String s = arr[i]; if (i < arrCount - 1) s += Environment.NewLine; - kpList.Add(new KeyValuePair(c.Style.Font, s)); + kpList.Add(new KeyValuePair(cellStyle.Font, s)); } } @@ -429,7 +429,7 @@ #endregion } else - thisWidthMax = c.Style.Font.GetWidth(c.GetFormattedString(), fontCache); + thisWidthMax = cellStyle.Font.GetWidth(c.GetFormattedString(), fontCache); if (autoFilterRows.Contains(c.Address.RowNumber)) thisWidthMax += 2.7148; // Allow room for arrow icon in autofilter @@ -588,7 +588,7 @@ column.Clear(); var newColumn = (XLColumn)column; newColumn._width = _width; - newColumn.Style = GetStyle(); + newColumn.InnerStyle = InnerStyle; using (var asRange = AsRange()) asRange.CopyTo(column).Dispose(); diff --git a/ClosedXML/Excel/ConditionalFormats/Save/XLCFCellIsConverter.cs b/ClosedXML/Excel/ConditionalFormats/Save/XLCFCellIsConverter.cs index 1d29af9..effbaca 100644 --- a/ClosedXML/Excel/ConditionalFormats/Save/XLCFCellIsConverter.cs +++ b/ClosedXML/Excel/ConditionalFormats/Save/XLCFCellIsConverter.cs @@ -10,9 +10,9 @@ String val = GetQuoted(cf.Values[1]); var conditionalFormattingRule = XLCFBaseConverter.Convert(cf, priority); - - if (!cf.Style.Value.Equals(XLWorkbook.DefaultStyle.Value)) - conditionalFormattingRule.FormatId = (UInt32)context.DifferentialFormats[cf.Style.Value.Key]; + var cfStyle = cf.Style.Value; + if (!cfStyle.Equals(XLWorkbook.DefaultStyle.Value)) + conditionalFormattingRule.FormatId = (UInt32)context.DifferentialFormats[cfStyle.Key]; conditionalFormattingRule.Operator = cf.Operator.ToOpenXml(); diff --git a/ClosedXML/Excel/ConditionalFormats/Save/XLCFContainsConverter.cs b/ClosedXML/Excel/ConditionalFormats/Save/XLCFContainsConverter.cs index 0a83028..bb25709 100644 --- a/ClosedXML/Excel/ConditionalFormats/Save/XLCFContainsConverter.cs +++ b/ClosedXML/Excel/ConditionalFormats/Save/XLCFContainsConverter.cs @@ -9,9 +9,9 @@ { String val = cf.Values[1].Value; var conditionalFormattingRule = XLCFBaseConverter.Convert(cf, priority); - - if (!cf.Style.Value.Equals(XLWorkbook.DefaultStyle.Value)) - conditionalFormattingRule.FormatId = (UInt32)context.DifferentialFormats[cf.Style.Value.Key]; + var cfStyle = cf.Style.Value; + if (!cfStyle.Equals(XLWorkbook.DefaultStyle.Value)) + conditionalFormattingRule.FormatId = (UInt32)context.DifferentialFormats[cfStyle.Key]; conditionalFormattingRule.Operator = ConditionalFormattingOperatorValues.ContainsText; conditionalFormattingRule.Text = val; diff --git a/ClosedXML/Excel/ConditionalFormats/Save/XLCFDatesOccuringConverter.cs b/ClosedXML/Excel/ConditionalFormats/Save/XLCFDatesOccuringConverter.cs index 2238881..82bcf6d 100644 --- a/ClosedXML/Excel/ConditionalFormats/Save/XLCFDatesOccuringConverter.cs +++ b/ClosedXML/Excel/ConditionalFormats/Save/XLCFDatesOccuringConverter.cs @@ -23,9 +23,9 @@ public ConditionalFormattingRule Convert(IXLConditionalFormat cf, int priority, XLWorkbook.SaveContext context) { var conditionalFormattingRule = XLCFBaseConverter.Convert(cf, priority); - - if (!cf.Style.Value.Equals(XLWorkbook.DefaultStyle)) - conditionalFormattingRule.FormatId = (UInt32)context.DifferentialFormats[cf.Style.Value.Key]; + var cfStyle = cf.Style.Value; + if (!cfStyle.Equals(XLWorkbook.DefaultStyle)) + conditionalFormattingRule.FormatId = (UInt32)context.DifferentialFormats[cfStyle.Key]; conditionalFormattingRule.TimePeriod = cf.TimePeriod.ToOpenXml(); diff --git a/ClosedXML/Excel/ConditionalFormats/Save/XLCFEndsWithConverter.cs b/ClosedXML/Excel/ConditionalFormats/Save/XLCFEndsWithConverter.cs index 3b967d0..fa0f6d5 100644 --- a/ClosedXML/Excel/ConditionalFormats/Save/XLCFEndsWithConverter.cs +++ b/ClosedXML/Excel/ConditionalFormats/Save/XLCFEndsWithConverter.cs @@ -9,9 +9,9 @@ { String val = cf.Values[1].Value; var conditionalFormattingRule = XLCFBaseConverter.Convert(cf, priority); - - if (!cf.Style.Value.Equals(XLWorkbook.DefaultStyle)) - conditionalFormattingRule.FormatId = (UInt32)context.DifferentialFormats[cf.Style.Value.Key]; + var cfStyle = cf.Style.Value; + if (!cfStyle.Equals(XLWorkbook.DefaultStyle)) + conditionalFormattingRule.FormatId = (UInt32)context.DifferentialFormats[cfStyle.Key]; conditionalFormattingRule.Operator = ConditionalFormattingOperatorValues.EndsWith; conditionalFormattingRule.Text = val; diff --git a/ClosedXML/Excel/ConditionalFormats/Save/XLCFIsBlankConverter.cs b/ClosedXML/Excel/ConditionalFormats/Save/XLCFIsBlankConverter.cs index d4f09f3..6d282a9 100644 --- a/ClosedXML/Excel/ConditionalFormats/Save/XLCFIsBlankConverter.cs +++ b/ClosedXML/Excel/ConditionalFormats/Save/XLCFIsBlankConverter.cs @@ -8,9 +8,9 @@ public ConditionalFormattingRule Convert(IXLConditionalFormat cf, int priority, XLWorkbook.SaveContext context) { var conditionalFormattingRule = XLCFBaseConverter.Convert(cf, priority); - - if (!cf.Style.Value.Equals(XLWorkbook.DefaultStyle.Value)) - conditionalFormattingRule.FormatId = (UInt32)context.DifferentialFormats[cf.Style.Value.Key]; + var cfStyle = cf.Style.Value; + if (!cfStyle.Equals(XLWorkbook.DefaultStyle.Value)) + conditionalFormattingRule.FormatId = (UInt32)context.DifferentialFormats[cfStyle.Key]; var formula = new Formula { Text = "LEN(TRIM(" + cf.Range.RangeAddress.FirstAddress.ToStringRelative(false) + "))=0" }; diff --git a/ClosedXML/Excel/ConditionalFormats/Save/XLCFIsErrorConverter.cs b/ClosedXML/Excel/ConditionalFormats/Save/XLCFIsErrorConverter.cs index 265fb41..bf2170f 100644 --- a/ClosedXML/Excel/ConditionalFormats/Save/XLCFIsErrorConverter.cs +++ b/ClosedXML/Excel/ConditionalFormats/Save/XLCFIsErrorConverter.cs @@ -8,9 +8,9 @@ public ConditionalFormattingRule Convert(IXLConditionalFormat cf, int priority, XLWorkbook.SaveContext context) { var conditionalFormattingRule = XLCFBaseConverter.Convert(cf, priority); - - if (!cf.Style.Value.Equals(XLWorkbook.DefaultStyle.Value)) - conditionalFormattingRule.FormatId = (UInt32)context.DifferentialFormats[cf.Style.Value.Key]; + var cfStyle = cf.Style.Value; + if (!cfStyle.Equals(XLWorkbook.DefaultStyle.Value)) + conditionalFormattingRule.FormatId = (UInt32)context.DifferentialFormats[cfStyle.Key]; var formula = new Formula { Text = "ISERROR(" + cf.Range.RangeAddress.FirstAddress.ToStringRelative(false) + ")" }; diff --git a/ClosedXML/Excel/ConditionalFormats/Save/XLCFNotBlankConverter.cs b/ClosedXML/Excel/ConditionalFormats/Save/XLCFNotBlankConverter.cs index 59ce073..532777a 100644 --- a/ClosedXML/Excel/ConditionalFormats/Save/XLCFNotBlankConverter.cs +++ b/ClosedXML/Excel/ConditionalFormats/Save/XLCFNotBlankConverter.cs @@ -8,9 +8,9 @@ public ConditionalFormattingRule Convert(IXLConditionalFormat cf, int priority, XLWorkbook.SaveContext context) { var conditionalFormattingRule = XLCFBaseConverter.Convert(cf, priority); - - if (!cf.Style.Value.Equals(XLWorkbook.DefaultStyle.Value)) - conditionalFormattingRule.FormatId = (UInt32)context.DifferentialFormats[cf.Style.Value.Key]; + var cfStyle = cf.Style.Value; + if (!cfStyle.Equals(XLWorkbook.DefaultStyle.Value)) + conditionalFormattingRule.FormatId = (UInt32)context.DifferentialFormats[cfStyle.Key]; var formula = new Formula { Text = "LEN(TRIM(" + cf.Range.RangeAddress.FirstAddress.ToStringRelative(false) + "))>0" }; diff --git a/ClosedXML/Excel/ConditionalFormats/Save/XLCFNotContainsConverter.cs b/ClosedXML/Excel/ConditionalFormats/Save/XLCFNotContainsConverter.cs index 5072e34..0c3bf31 100644 --- a/ClosedXML/Excel/ConditionalFormats/Save/XLCFNotContainsConverter.cs +++ b/ClosedXML/Excel/ConditionalFormats/Save/XLCFNotContainsConverter.cs @@ -9,9 +9,9 @@ { String val = cf.Values[1].Value; var conditionalFormattingRule = XLCFBaseConverter.Convert(cf, priority); - - if (!cf.Style.Value.Equals(XLWorkbook.DefaultStyle)) - conditionalFormattingRule.FormatId = (UInt32)context.DifferentialFormats[cf.Style.Value.Key]; + var cfStyle = cf.Style.Value; + if (!cfStyle.Equals(XLWorkbook.DefaultStyle)) + conditionalFormattingRule.FormatId = (UInt32)context.DifferentialFormats[cfStyle.Key]; conditionalFormattingRule.Operator = ConditionalFormattingOperatorValues.NotContains; conditionalFormattingRule.Text = val; diff --git a/ClosedXML/Excel/ConditionalFormats/Save/XLCFNotErrorConverter.cs b/ClosedXML/Excel/ConditionalFormats/Save/XLCFNotErrorConverter.cs index 703ec43..7798815 100644 --- a/ClosedXML/Excel/ConditionalFormats/Save/XLCFNotErrorConverter.cs +++ b/ClosedXML/Excel/ConditionalFormats/Save/XLCFNotErrorConverter.cs @@ -8,9 +8,9 @@ public ConditionalFormattingRule Convert(IXLConditionalFormat cf, int priority, XLWorkbook.SaveContext context) { var conditionalFormattingRule = XLCFBaseConverter.Convert(cf, priority); - - if (!cf.Style.Value.Equals(XLWorkbook.DefaultStyle.Value)) - conditionalFormattingRule.FormatId = (UInt32)context.DifferentialFormats[cf.Style.Value.Key]; + var cfStyle = cf.Style.Value; + if (!cfStyle.Equals(XLWorkbook.DefaultStyle.Value)) + conditionalFormattingRule.FormatId = (UInt32)context.DifferentialFormats[cfStyle.Key]; var formula = new Formula { Text = "NOT(ISERROR(" + cf.Range.RangeAddress.FirstAddress.ToStringRelative(false) + "))" }; diff --git a/ClosedXML/Excel/ConditionalFormats/Save/XLCFStartsWithConverter.cs b/ClosedXML/Excel/ConditionalFormats/Save/XLCFStartsWithConverter.cs index 0c5c79c..1ede504 100644 --- a/ClosedXML/Excel/ConditionalFormats/Save/XLCFStartsWithConverter.cs +++ b/ClosedXML/Excel/ConditionalFormats/Save/XLCFStartsWithConverter.cs @@ -9,9 +9,9 @@ { String val = cf.Values[1].Value; var conditionalFormattingRule = XLCFBaseConverter.Convert(cf, priority); - - if (!cf.Style.Value.Equals(XLWorkbook.DefaultStyle.Value)) - conditionalFormattingRule.FormatId = (UInt32)context.DifferentialFormats[cf.Style.Value.Key]; + var cfStyle = cf.Style.Value; + if (!cfStyle.Equals(XLWorkbook.DefaultStyle.Value)) + conditionalFormattingRule.FormatId = (UInt32)context.DifferentialFormats[cfStyle.Key]; conditionalFormattingRule.Operator = ConditionalFormattingOperatorValues.BeginsWith; conditionalFormattingRule.Text = val; diff --git a/ClosedXML/Excel/ConditionalFormats/Save/XLCFTopConverter.cs b/ClosedXML/Excel/ConditionalFormats/Save/XLCFTopConverter.cs index b8d7338..194f183 100644 --- a/ClosedXML/Excel/ConditionalFormats/Save/XLCFTopConverter.cs +++ b/ClosedXML/Excel/ConditionalFormats/Save/XLCFTopConverter.cs @@ -9,9 +9,9 @@ { UInt32 val = UInt32.Parse(cf.Values[1].Value); var conditionalFormattingRule = XLCFBaseConverter.Convert(cf, priority); - - if (!cf.Style.Value.Equals(XLWorkbook.DefaultStyle.Value)) - conditionalFormattingRule.FormatId = (UInt32)context.DifferentialFormats[cf.Style.Value.Key]; + var cfStyle = cf.Style.Value; + if (!cfStyle.Equals(XLWorkbook.DefaultStyle.Value)) + conditionalFormattingRule.FormatId = (UInt32)context.DifferentialFormats[cfStyle.Key]; conditionalFormattingRule.Percent = cf.Percent; conditionalFormattingRule.Rank = val; diff --git a/ClosedXML/Excel/ConditionalFormats/Save/XLCFUniqueConverter.cs b/ClosedXML/Excel/ConditionalFormats/Save/XLCFUniqueConverter.cs index 600e9bc..673fae8 100644 --- a/ClosedXML/Excel/ConditionalFormats/Save/XLCFUniqueConverter.cs +++ b/ClosedXML/Excel/ConditionalFormats/Save/XLCFUniqueConverter.cs @@ -8,9 +8,9 @@ public ConditionalFormattingRule Convert(IXLConditionalFormat cf, int priority, XLWorkbook.SaveContext context) { var conditionalFormattingRule = XLCFBaseConverter.Convert(cf, priority); - - if (!cf.Style.Value.Equals(XLWorkbook.DefaultStyle.Value)) - conditionalFormattingRule.FormatId = (UInt32)context.DifferentialFormats[cf.Style.Value.Key]; + var cfStyle = cf.Style.Value; + if (!cfStyle.Equals(XLWorkbook.DefaultStyle.Value)) + conditionalFormattingRule.FormatId = (UInt32)context.DifferentialFormats[cfStyle.Key]; return conditionalFormattingRule; } diff --git a/ClosedXML/Excel/ConditionalFormats/XLConditionalFormat.cs b/ClosedXML/Excel/ConditionalFormats/XLConditionalFormat.cs index 5e8b530..48d247d 100644 --- a/ClosedXML/Excel/ConditionalFormats/XLConditionalFormat.cs +++ b/ClosedXML/Excel/ConditionalFormats/XLConditionalFormat.cs @@ -188,7 +188,7 @@ public void CopyFrom(IXLConditionalFormat other) { - Style = other.Style; + InnerStyle = other.Style; ConditionalFormatType = other.ConditionalFormatType; TimePeriod = other.TimePeriod; IconSetStyle = other.IconSetStyle; diff --git a/ClosedXML/Excel/Hyperlinks/XLHyperlink_public.cs b/ClosedXML/Excel/Hyperlinks/XLHyperlink_public.cs index f60e516..85b7e89 100644 --- a/ClosedXML/Excel/Hyperlinks/XLHyperlink_public.cs +++ b/ClosedXML/Excel/Hyperlinks/XLHyperlink_public.cs @@ -98,9 +98,9 @@ if (Cell == null) return; Worksheet.Hyperlinks.Delete(Cell.Address); if (Cell.Style.Font.FontColor.Equals(XLColor.FromTheme(XLThemeColor.Hyperlink))) - Cell.Style.Font.FontColor = Worksheet.Style.Font.FontColor; + Cell.Style.Font.FontColor = Worksheet.StyleValue.Font.FontColor; - Cell.Style.Font.Underline = Worksheet.Style.Font.Underline; + Cell.Style.Font.Underline = Worksheet.StyleValue.Font.Underline; } } } diff --git a/ClosedXML/Excel/Rows/XLRow.cs b/ClosedXML/Excel/Rows/XLRow.cs index b8fe358..37d4a2e 100644 --- a/ClosedXML/Excel/Rows/XLRow.cs +++ b/ClosedXML/Excel/Rows/XLRow.cs @@ -304,7 +304,7 @@ foreach (XLCell c in from XLCell c in Row(startColumn, endColumn).CellsUsed() where !c.IsMerged() select c) { Double thisHeight; - Int32 textRotation = c.Style.Alignment.TextRotation; + Int32 textRotation = c.StyleValue.Alignment.TextRotation; if (c.HasRichText || textRotation != 0 || c.InnerText.Contains(Environment.NewLine)) { var kpList = new List>(); @@ -518,7 +518,7 @@ row.Clear(); var newRow = (XLRow)row; newRow._height = _height; - newRow.Style = GetStyle(); + newRow.InnerStyle = GetStyle(); using (var asRange = AsRange()) asRange.CopyTo(row).Dispose(); @@ -623,11 +623,11 @@ Worksheet.Internals.RowsCollection[RowNumber()].SetStyleNoColumns(value); else { - Style = value; + InnerStyle = value; int row = RowNumber(); foreach (XLCell c in Worksheet.Internals.CellsCollection.GetCellsInRow(row)) - c.Style = value; + c.InnerStyle = value; } } diff --git a/ClosedXML/Excel/Tables/XLTableField.cs b/ClosedXML/Excel/Tables/XLTableField.cs index c007643..55efcb0 100644 --- a/ClosedXML/Excel/Tables/XLTableField.cs +++ b/ClosedXML/Excel/Tables/XLTableField.cs @@ -160,16 +160,14 @@ var styles = this.Column .Cells() .Skip(this.table.ShowHeaderRow ? 1 : 0) - .Select(c => c.Style.Value); + .OfType() + .Select(c => c.StyleValue); if (this.table.ShowTotalsRow) styles = styles.Take(styles.Count() - 1); var distinctStyles = styles - .GroupBy(f => f) - .Select(g => new { Key = g.Key, Count = g.Count() }); - - var ie = distinctStyles.First().Key.Equals(distinctStyles.Last().Key); + .Distinct(); return distinctStyles.Count() == 1; }