From b4386c0f0bcd07d4c8e15cc98f3659e96f7a687d Mon Sep 17 00:00:00 2001 From: "olga.karpova" Date: Fri, 20 Sep 2024 13:11:25 +0400 Subject: [PATCH] Add horizontal alignment "fill" to cell --- .../Excel.TemplateEngine.Tests.csproj | 2 +- .../FileGeneratingTests/ExcelStyleTests.cs | 11 +- .../FileGeneratingTests/Files/template.xlsx | Bin 9951 -> 9977 bytes .../Files/complexTemplate.xlsx | Bin 9069 -> 9800 bytes .../ObjectExcelPrintingTests.cs | 2 +- .../Caches/CacheItems/AlignmentCacheItem.cs | 148 +++--- .../Implementations/ExcelDocumentStyle.cs | 443 +++++++++--------- .../DataTypes/ExcelHorizontalAlignment.cs | 16 +- 8 files changed, 302 insertions(+), 320 deletions(-) diff --git a/Excel.TemplateEngine.Tests/Excel.TemplateEngine.Tests.csproj b/Excel.TemplateEngine.Tests/Excel.TemplateEngine.Tests.csproj index 9cef4ce..7b6507e 100644 --- a/Excel.TemplateEngine.Tests/Excel.TemplateEngine.Tests.csproj +++ b/Excel.TemplateEngine.Tests/Excel.TemplateEngine.Tests.csproj @@ -11,7 +11,7 @@ - + diff --git a/Excel.TemplateEngine.Tests/FileGeneratingTests/ExcelStyleTests.cs b/Excel.TemplateEngine.Tests/FileGeneratingTests/ExcelStyleTests.cs index 56a37be..9dd8175 100644 --- a/Excel.TemplateEngine.Tests/FileGeneratingTests/ExcelStyleTests.cs +++ b/Excel.TemplateEngine.Tests/FileGeneratingTests/ExcelStyleTests.cs @@ -13,7 +13,7 @@ using Vostok.Logging.Console; -namespace SkbKontur.Excel.TemplateEngine.Tests.FileGeneratingTests +namespace SkbKontur.Excel.TemplateEngine.Tests.FileGeneratingTests { public class ExcelStyleTests : FileBasedTestBase { @@ -109,15 +109,16 @@ public void CellBorderFormatExtractionTest() style.BordersStyle.BottomBorder.Color.Blue.Should().Be(255); } - [Test] - public void CellAlignmentExtractionTest() + [TestCase(ExcelHorizontalAlignment.Left, "A1")] + [TestCase(ExcelHorizontalAlignment.Fill, "B1")] + public void CellAlignmentExtractionTest(ExcelHorizontalAlignment horizontalAlignment, string cellIndex) { var templateDocument = ExcelDocumentFactory.CreateFromTemplate(File.ReadAllBytes(GetFilePath("template.xlsx")), logger); - var cell = templateDocument.GetWorksheet(0).GetCell(new ExcelCellIndex("A1")); + var cell = templateDocument.GetWorksheet(0).GetCell(new ExcelCellIndex(cellIndex)); var style = cell.GetStyle(); style.Alignment.WrapText.Should().BeTrue(); - style.Alignment.HorizontalAlignment.Should().Be(ExcelHorizontalAlignment.Left); + style.Alignment.HorizontalAlignment.Should().Be(horizontalAlignment); } [Test] diff --git a/Excel.TemplateEngine.Tests/FileGeneratingTests/Files/template.xlsx b/Excel.TemplateEngine.Tests/FileGeneratingTests/Files/template.xlsx index ef83af1fd27bb5f3a2a27697c6e2a0e76a17abd9..eb7c7741db4cc9d9f8ebdcc8354777ba03d36bba 100644 GIT binary patch delta 3496 zcmZ8k2QVDm{$1T#Rt=(uRU>*AmR&(2YN9-138F-avbxRcQ5MT0SZ$RRk|@zuNf1#Y zM2nIySS=xXVv$GilDz-_y>H%c=FXkD=iK?ty?5rGbI7LuG_7X=(k6+slW^=nS!#`H z9296kMa0Deznfn$Jhh8ZXm5&3@jlBs0e>0GEkK~!1#%kB_f{4gMo1h`zK6&Al%s#n z>_7ORNeqpTLouCQJYu$ZJBG)gPExUYz;T96oF%(!~ACr(Z?baSZEja}_6 z-fU6usMa%+O&hbWeIy_@;XreGP7@1rswC9GPu#n<%c5GKAqd@%tS8p5tb{km227k; zax$#L{mAclPP};d2QR#19@}?$ZE)O;40ifUSy^hs#(|Xic3*bhV4!;+^R>WxRn>D< zwe=+Z7SdAZil7o$J4Wg{lSR$@!nd?a5u&cW`ksG@$!&95RV5}m^(uMnwZ=`p0T#Mf znLQ_VVXf*63_P0@wZHKpQkxt{w@DSjbGoyHX+_ep*pmF8t8O%7USvSGa43d^;g zn=6IqO+iY_xSCs*cF27Jzl1+_q=4V19UI@s&6=&v8ZJxy$3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(Pqj9Gw~s3sO%;h>D$1) z5Yr*N{==5BWe-#ZUBU9j2bDV5$U$aAE(U!7;i5PEQ7U@cmKFHT1+Q=4_; z8VO{gbArqO2!CqKCmhTC(ae;o;WQ=864FR&l+-~*8ZK` zG5DV16?Pzt@pGo^PWEg+5h}4&zsi(~=L@&>VDAu%NWcD3e?>v)Fy*w^wWWMq`6tw4 zDDWL0t;Q>5OAQXIPS!uqF`k|a%80_VJ*1ZO=GfX&*p3E~A8oyj%-)Q;xb9`|`*I(g za>ru=myl6%Oc%lvaU&^Hpp~ZDL{XO1&5Rq%Y7coN&}yjCn%MqZz!LjsWkoHa5pi|n%a3BVw75w! z>5hD3Zo5gdOR4{W}^%!Y##{+okJA!cHtKR*N)1VA1L{`ab8nvT^G1Nl;+4GwLeL~W(a_A!Ke%3HYJhjNMb`zgnstg7_GMkoyy zLR}5N_^s-DeLz4t?8TS+PYLD*>8hgc>cS^Ik4~?QSdM%qpF#Wx1Vm9;2Bf}+H&1!x zg8e|~A^4^6Z)ri|_21TqC=Lhz<4lO}#7%)(Ohj)c z38IOF3>A_XBq7QF|62N&oc`|;AvQ~h2>dh2AOHZ*|3bgd9v&h)FP|*hkP0aO%kzK$ z^uJ(H!0-R?%L!qAIU)9cB}@?!lH&ZopZN=)|Fxz56*ndZOPW#55Jx1TpaSS$q5l9u CbYIT^ diff --git a/Excel.TemplateEngine.Tests/ObjectPrintingTests/Files/complexTemplate.xlsx b/Excel.TemplateEngine.Tests/ObjectPrintingTests/Files/complexTemplate.xlsx index d41266ba7507844a3fc3d1ff205cbcec37be8f9c..ae2cd02aac310e6aa2a922ee69959e61def41ac5 100644 GIT binary patch literal 9800 zcmeHtgU9G>oLgAR(oMbR#K9cc-LuH`3kt9nU%U zdJfm$?;p5#&u8}j?AiN$X6^O9&%4%o-mRg6giH)T1)u`}06KuQkWar20sw%F0ss&J z&=Cz}AvTU68%HB;s4d9BkjoWpO`C>{$eIE`gx~+a?Z3DO^0m8cntAZ+^fn~r>U9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iN3b+51U5L@FR{ zmym20?Pur(tshdgnDf+{mXummtFJ1$ZbmRK zGs$*bB}7*b?pBA1p6mDUaNYb=y8_$+oRojrNNPXA-iy%anUferBg z{hEN%(+Cs(d7&x2IH#{(&i{-ws22@2;nmAT^9x4u5AYIoK&xojNdK?v`VZv_dPhSK zY=u(N5Ce6$Q?|F}v3!0UgAFOee#bOMtA3a7;(1O6Ym{txftYv?OFFxmeI2wVVw z=pXbYI(!2yBO-ws(czH&yQg2wV6~Uqe&PMEkxB}UrlTSIcd@<@@L#?RaQ+tz0ANu- UDd|bDKmZUR@a5_`%73B%1!!thegFUf diff --git a/Excel.TemplateEngine.Tests/ObjectPrintingTests/ObjectExcelPrintingTests.cs b/Excel.TemplateEngine.Tests/ObjectPrintingTests/ObjectExcelPrintingTests.cs index 47df763..edea614 100644 --- a/Excel.TemplateEngine.Tests/ObjectPrintingTests/ObjectExcelPrintingTests.cs +++ b/Excel.TemplateEngine.Tests/ObjectPrintingTests/ObjectExcelPrintingTests.cs @@ -119,7 +119,7 @@ public void PrintComplexObjectTest() }, DeliveryParty = new Organization { - Address = "DeliveryPartyAddress", + Address = "DeliveryPartyAddress,DeliveryPartyAddress,DeliveryPartyAddress", Name = "DeliveryPartyName" }, Vehicle = new VehicleInfo diff --git a/Excel.TemplateEngine/FileGenerating/Caches/CacheItems/AlignmentCacheItem.cs b/Excel.TemplateEngine/FileGenerating/Caches/CacheItems/AlignmentCacheItem.cs index 02b87ea..9d8b291 100644 --- a/Excel.TemplateEngine/FileGenerating/Caches/CacheItems/AlignmentCacheItem.cs +++ b/Excel.TemplateEngine/FileGenerating/Caches/CacheItems/AlignmentCacheItem.cs @@ -5,101 +5,81 @@ using SkbKontur.Excel.TemplateEngine.FileGenerating.DataTypes; -namespace SkbKontur.Excel.TemplateEngine.FileGenerating.Caches.CacheItems +namespace SkbKontur.Excel.TemplateEngine.FileGenerating.Caches.CacheItems; + +internal class AlignmentCacheItem : IEquatable { - internal class AlignmentCacheItem : IEquatable + public AlignmentCacheItem(ExcelCellAlignment cellAlignment) { - public AlignmentCacheItem(ExcelCellAlignment cellAlignment) - { - verticalAlignment = cellAlignment.VerticalAlignment; - horizontalAlignment = cellAlignment.HorizontalAlignment; - wrapText = cellAlignment.WrapText; - } + verticalAlignment = cellAlignment.VerticalAlignment; + horizontalAlignment = cellAlignment.HorizontalAlignment; + wrapText = cellAlignment.WrapText; + } - public bool Equals(AlignmentCacheItem other) - { - if (ReferenceEquals(null, other)) return false; - if (ReferenceEquals(this, other)) return true; - return verticalAlignment == other.verticalAlignment && horizontalAlignment == other.horizontalAlignment && wrapText.Equals(other.wrapText); - } + public bool Equals(AlignmentCacheItem other) + { + if (ReferenceEquals(null, other)) return false; + if (ReferenceEquals(this, other)) return true; + return verticalAlignment == other.verticalAlignment && horizontalAlignment == other.horizontalAlignment && wrapText.Equals(other.wrapText); + } - public Alignment ToAlignment() - { - return new Alignment - { - Horizontal = GetHorizontalAlignment(), - Vertical = GetVerticalAlignment(), - WrapText = wrapText ? new BooleanValue(true) : null - }; - } + public Alignment ToAlignment() + { + return new Alignment + { + Horizontal = GetHorizontalAlignment(), + Vertical = GetVerticalAlignment(), + WrapText = wrapText ? new BooleanValue(true) : null + }; + } - public override bool Equals(object obj) - { - if (ReferenceEquals(null, obj)) return false; - if (ReferenceEquals(this, obj)) return true; - if (obj.GetType() != GetType()) return false; - return Equals((AlignmentCacheItem)obj); - } + public override bool Equals(object obj) + { + if (ReferenceEquals(null, obj)) return false; + if (ReferenceEquals(this, obj)) return true; + if (obj.GetType() != GetType()) return false; + return Equals((AlignmentCacheItem)obj); + } - public override int GetHashCode() + public override int GetHashCode() + { + unchecked { - unchecked - { - var hashCode = (int)verticalAlignment; - hashCode = (hashCode * 397) ^ (int)horizontalAlignment; - hashCode = (hashCode * 397) ^ wrapText.GetHashCode(); - return hashCode; - } + var hashCode = (int)verticalAlignment; + hashCode = (hashCode * 397) ^ (int)horizontalAlignment; + hashCode = (hashCode * 397) ^ wrapText.GetHashCode(); + return hashCode; } + } - private EnumValue GetVerticalAlignment() - { - EnumValue result; - switch (verticalAlignment) + private EnumValue GetVerticalAlignment() + { + EnumValue result = verticalAlignment switch { - case ExcelVerticalAlignment.Top: - result = new EnumValue(VerticalAlignmentValues.Top); - break; - case ExcelVerticalAlignment.Center: - result = new EnumValue(VerticalAlignmentValues.Center); - break; - case ExcelVerticalAlignment.Bottom: - result = new EnumValue(VerticalAlignmentValues.Bottom); - break; - case ExcelVerticalAlignment.Default: - result = null; - break; - default: - throw new InvalidOperationException($"Unknown vertical alignment: {verticalAlignment}"); - } - return result; - } + ExcelVerticalAlignment.Top => new EnumValue(VerticalAlignmentValues.Top), + ExcelVerticalAlignment.Center => new EnumValue(VerticalAlignmentValues.Center), + ExcelVerticalAlignment.Bottom => new EnumValue(VerticalAlignmentValues.Bottom), + ExcelVerticalAlignment.Default => null, + _ => throw new InvalidOperationException($"Unknown vertical alignment: {verticalAlignment}") + }; + return result; + } - private EnumValue GetHorizontalAlignment() - { - EnumValue result; - switch (horizontalAlignment) + private EnumValue GetHorizontalAlignment() + { + EnumValue result = horizontalAlignment switch { - case ExcelHorizontalAlignment.Left: - result = new EnumValue(HorizontalAlignmentValues.Left); - break; - case ExcelHorizontalAlignment.Center: - result = new EnumValue(HorizontalAlignmentValues.Center); - break; - case ExcelHorizontalAlignment.Right: - result = new EnumValue(HorizontalAlignmentValues.Right); - break; - case ExcelHorizontalAlignment.Default: - result = null; - break; - default: - throw new InvalidOperationException($"Unknown horizontal alignment: {horizontalAlignment}"); - } - return result; - } - - private readonly ExcelVerticalAlignment verticalAlignment; - private readonly ExcelHorizontalAlignment horizontalAlignment; - private readonly bool wrapText; + ExcelHorizontalAlignment.Left => new EnumValue(HorizontalAlignmentValues.Left), + ExcelHorizontalAlignment.Center => new EnumValue(HorizontalAlignmentValues.Center), + ExcelHorizontalAlignment.Right => new EnumValue(HorizontalAlignmentValues.Right), + ExcelHorizontalAlignment.Fill => new EnumValue(HorizontalAlignmentValues.Fill), + ExcelHorizontalAlignment.Default => null, + _ => throw new InvalidOperationException($"Unknown horizontal alignment: {horizontalAlignment}") + }; + return result; } + + private readonly ExcelVerticalAlignment verticalAlignment; + private readonly ExcelHorizontalAlignment horizontalAlignment; + private readonly bool wrapText; } \ No newline at end of file diff --git a/Excel.TemplateEngine/FileGenerating/Caches/Implementations/ExcelDocumentStyle.cs b/Excel.TemplateEngine/FileGenerating/Caches/Implementations/ExcelDocumentStyle.cs index b34c499..2f17571 100644 --- a/Excel.TemplateEngine/FileGenerating/Caches/Implementations/ExcelDocumentStyle.cs +++ b/Excel.TemplateEngine/FileGenerating/Caches/Implementations/ExcelDocumentStyle.cs @@ -17,257 +17,258 @@ using ColorType = DocumentFormat.OpenXml.Spreadsheet.ColorType; using Fill = DocumentFormat.OpenXml.Spreadsheet.Fill; -namespace SkbKontur.Excel.TemplateEngine.FileGenerating.Caches.Implementations +namespace SkbKontur.Excel.TemplateEngine.FileGenerating.Caches.Implementations; + +internal class ExcelDocumentStyle : IExcelDocumentStyle { - internal class ExcelDocumentStyle : IExcelDocumentStyle + public ExcelDocumentStyle(Stylesheet stylesheet, Theme theme, ILog logger) { - public ExcelDocumentStyle(Stylesheet stylesheet, Theme theme, ILog logger) - { - this.stylesheet = stylesheet; - this.logger = logger; - numberingFormats = new ExcelDocumentNumberingFormats(stylesheet); - fillStyles = new ExcelDocumentFillStyles(stylesheet); - bordersStyles = new ExcelDocumentBordersStyles(stylesheet); - fontStyles = new ExcelDocumentFontStyles(stylesheet); - // Not using theme.ThemeElements.ColorScheme.Elements() here because of wrong order. - colorSchemeElements = new List - { - theme.ThemeElements?.ColorScheme?.Light1Color, - theme.ThemeElements?.ColorScheme?.Dark1Color, - theme.ThemeElements?.ColorScheme?.Light2Color, - theme.ThemeElements?.ColorScheme?.Dark2Color, - theme.ThemeElements?.ColorScheme?.Accent1Color, - theme.ThemeElements?.ColorScheme?.Accent2Color, - theme.ThemeElements?.ColorScheme?.Accent3Color, - theme.ThemeElements?.ColorScheme?.Accent4Color, - theme.ThemeElements?.ColorScheme?.Accent5Color, - theme.ThemeElements?.ColorScheme?.Accent6Color, - theme.ThemeElements?.ColorScheme?.Hyperlink, - theme.ThemeElements?.ColorScheme?.FollowedHyperlinkColor, - }; - cache = new Dictionary(); - inverseCache = new Dictionary(); - } - - public uint AddStyle(ExcelCellStyle style) - { - var fillId = fillStyles.AddStyle(style.FillStyle); - var fontId = fontStyles.AddFont(style.FontStyle); - var borderId = bordersStyles.AddStyle(style.BordersStyle); - var numberFormatId = numberingFormats.AddFormat(style.NumberingFormat); - var alignment = Alignment(style.Alignment); - var cacheItem = new CellStyleCacheItem - { - FillId = fillId, - FontId = fontId, - BorderId = borderId, - NumberFormatId = numberFormatId, - Alignment = alignment - }; - if (!cache.TryGetValue(cacheItem, out var result) && stylesheet.CellFormats != null) + this.stylesheet = stylesheet; + this.logger = logger; + numberingFormats = new ExcelDocumentNumberingFormats(stylesheet); + fillStyles = new ExcelDocumentFillStyles(stylesheet); + bordersStyles = new ExcelDocumentBordersStyles(stylesheet); + fontStyles = new ExcelDocumentFontStyles(stylesheet); + // Not using theme.ThemeElements.ColorScheme.Elements() here because of wrong order. + colorSchemeElements = new List { - result = stylesheet.CellFormats.Count; - stylesheet.CellFormats.Count++; - stylesheet.CellFormats.AppendChild(cacheItem.ToCellFormat()); - cache.Add(cacheItem, result); - } - return result; - } + theme.ThemeElements?.ColorScheme?.Light1Color, + theme.ThemeElements?.ColorScheme?.Dark1Color, + theme.ThemeElements?.ColorScheme?.Light2Color, + theme.ThemeElements?.ColorScheme?.Dark2Color, + theme.ThemeElements?.ColorScheme?.Accent1Color, + theme.ThemeElements?.ColorScheme?.Accent2Color, + theme.ThemeElements?.ColorScheme?.Accent3Color, + theme.ThemeElements?.ColorScheme?.Accent4Color, + theme.ThemeElements?.ColorScheme?.Accent5Color, + theme.ThemeElements?.ColorScheme?.Accent6Color, + theme.ThemeElements?.ColorScheme?.Hyperlink, + theme.ThemeElements?.ColorScheme?.FollowedHyperlinkColor, + }; + cache = new Dictionary(); + inverseCache = new Dictionary(); + } - public ExcelCellStyle GetStyle(int styleIndex) + public uint AddStyle(ExcelCellStyle style) + { + var fillId = fillStyles.AddStyle(style.FillStyle); + var fontId = fontStyles.AddFont(style.FontStyle); + var borderId = bordersStyles.AddStyle(style.BordersStyle); + var numberFormatId = numberingFormats.AddFormat(style.NumberingFormat); + var alignment = Alignment(style.Alignment); + var cacheItem = new CellStyleCacheItem + { + FillId = fillId, + FontId = fontId, + BorderId = borderId, + NumberFormatId = numberFormatId, + Alignment = alignment + }; + if (!cache.TryGetValue(cacheItem, out var result) && stylesheet.CellFormats != null) { - if (inverseCache.TryGetValue((uint)styleIndex, out var result)) - return result; - - var cellFormat = stylesheet?.CellFormats?.ChildElements.Count > styleIndex ? (CellFormat)stylesheet.CellFormats.ChildElements[styleIndex] : null; - result = new ExcelCellStyle - { - FillStyle = cellFormat?.FillId == null ? null : GetCellFillStyle(cellFormat.FillId.Value), - FontStyle = cellFormat?.FontId == null ? null : GetCellFontStyle(cellFormat.FontId.Value), - NumberingFormat = cellFormat?.NumberFormatId == null ? null : GetCellNumberingFormat(cellFormat.NumberFormatId.Value), - BordersStyle = cellFormat?.BorderId == null ? null : GetCellBordersStyle(cellFormat.BorderId.Value), - Alignment = cellFormat?.Alignment == null ? null : GetCellAlignment(cellFormat.Alignment) - }; - inverseCache.Add((uint)styleIndex, result); + result = stylesheet.CellFormats.Count; + stylesheet.CellFormats.Count++; + stylesheet.CellFormats.AppendChild(cacheItem.ToCellFormat()); + cache.Add(cacheItem, result); + } + return result; + } + public ExcelCellStyle GetStyle(int styleIndex) + { + if (inverseCache.TryGetValue((uint)styleIndex, out var result)) return result; - } - private ExcelCellAlignment GetCellAlignment(Alignment alignment) - { - return new ExcelCellAlignment - { - WrapText = true, //alignment.With(a => a.WrapText) != null && alignment.WrapText.Value, всегда делать перенос по словам - HorizontalAlignment = alignment?.Horizontal == null ? ExcelHorizontalAlignment.Default : ToExcelHorizontalAlignment(alignment.Horizontal), - VerticalAlignment = alignment?.Vertical == null ? ExcelVerticalAlignment.Default : ToExcelVerticalAlignment(alignment.Vertical) - }; - } + var cellFormat = stylesheet?.CellFormats?.ChildElements.Count > styleIndex ? (CellFormat)stylesheet.CellFormats.ChildElements[styleIndex] : null; + result = new ExcelCellStyle + { + FillStyle = cellFormat?.FillId == null ? null : GetCellFillStyle(cellFormat.FillId.Value), + FontStyle = cellFormat?.FontId == null ? null : GetCellFontStyle(cellFormat.FontId.Value), + NumberingFormat = cellFormat?.NumberFormatId == null ? null : GetCellNumberingFormat(cellFormat.NumberFormatId.Value), + BordersStyle = cellFormat?.BorderId == null ? null : GetCellBordersStyle(cellFormat.BorderId.Value), + Alignment = cellFormat?.Alignment == null ? null : GetCellAlignment(cellFormat.Alignment) + }; + inverseCache.Add((uint)styleIndex, result); - private ExcelVerticalAlignment ToExcelVerticalAlignment(EnumValue vertical) - { - if (vertical.Value == VerticalAlignmentValues.Bottom) - return ExcelVerticalAlignment.Bottom; - if (vertical.Value == VerticalAlignmentValues.Center) - return ExcelVerticalAlignment.Center; - if (vertical.Value == VerticalAlignmentValues.Top) - return ExcelVerticalAlignment.Top; - return ExcelVerticalAlignment.Default; - } + return result; + } - private ExcelHorizontalAlignment ToExcelHorizontalAlignment(EnumValue horizontal) - { - if (horizontal.Value == HorizontalAlignmentValues.Center) - return ExcelHorizontalAlignment.Center; - if (horizontal.Value == HorizontalAlignmentValues.Left) - return ExcelHorizontalAlignment.Left; - if (horizontal.Value == HorizontalAlignmentValues.Right) - return ExcelHorizontalAlignment.Right; - return ExcelHorizontalAlignment.Default; - } + private ExcelCellAlignment GetCellAlignment(Alignment alignment) + { + return new ExcelCellAlignment + { + WrapText = true, //alignment.With(a => a.WrapText) != null && alignment.WrapText.Value, всегда делать перенос по словам + HorizontalAlignment = alignment?.Horizontal == null ? ExcelHorizontalAlignment.Default : ToExcelHorizontalAlignment(alignment.Horizontal), + VerticalAlignment = alignment?.Vertical == null ? ExcelVerticalAlignment.Default : ToExcelVerticalAlignment(alignment.Vertical) + }; + } - private ExcelCellBordersStyle GetCellBordersStyle(uint borderId) - { - var bordersStyle = stylesheet?.Borders?.ChildElements.Count > borderId ? (Border)stylesheet.Borders.ChildElements[(int)borderId] : null; - return new ExcelCellBordersStyle - { - LeftBorder = bordersStyle?.LeftBorder == null ? null : GetBorderStyle(bordersStyle.LeftBorder), - RightBorder = bordersStyle?.RightBorder == null ? null : GetBorderStyle(bordersStyle.RightBorder), - TopBorder = bordersStyle?.TopBorder == null ? null : GetBorderStyle(bordersStyle.TopBorder), - BottomBorder = bordersStyle?.BottomBorder == null ? null : GetBorderStyle(bordersStyle.BottomBorder) - }; - } + private ExcelVerticalAlignment ToExcelVerticalAlignment(EnumValue vertical) + { + if (vertical.Value == VerticalAlignmentValues.Bottom) + return ExcelVerticalAlignment.Bottom; + if (vertical.Value == VerticalAlignmentValues.Center) + return ExcelVerticalAlignment.Center; + if (vertical.Value == VerticalAlignmentValues.Top) + return ExcelVerticalAlignment.Top; + return ExcelVerticalAlignment.Default; + } - private ExcelCellBorderStyle GetBorderStyle(BorderPropertiesType border) - { - return new ExcelCellBorderStyle - { - Color = ToExcelColor(border?.Color), - BorderType = border?.Style == null ? ExcelBorderType.None : ToExcelBorderType(border.Style) - }; - } + private ExcelHorizontalAlignment ToExcelHorizontalAlignment(EnumValue horizontal) + { + if (horizontal.Value == HorizontalAlignmentValues.Center) + return ExcelHorizontalAlignment.Center; + if (horizontal.Value == HorizontalAlignmentValues.Left) + return ExcelHorizontalAlignment.Left; + if (horizontal.Value == HorizontalAlignmentValues.Right) + return ExcelHorizontalAlignment.Right; + if (horizontal.Value == HorizontalAlignmentValues.Fill) + return ExcelHorizontalAlignment.Fill; + return ExcelHorizontalAlignment.Default; + } - private static ExcelBorderType ToExcelBorderType(EnumValue borderStyle) - { - if (borderStyle.Value == BorderStyleValues.None) - return ExcelBorderType.None; - if (borderStyle.Value == BorderStyleValues.Thin) - return ExcelBorderType.Thin; - if (borderStyle.Value == BorderStyleValues.Medium) - return ExcelBorderType.Single; - if (borderStyle.Value == BorderStyleValues.Thick) - return ExcelBorderType.Bold; - if (borderStyle.Value == BorderStyleValues.Double) - return ExcelBorderType.Double; - throw new InvalidOperationException($"Unknown border type: {borderStyle}"); - } + private ExcelCellBordersStyle GetCellBordersStyle(uint borderId) + { + var bordersStyle = stylesheet?.Borders?.ChildElements.Count > borderId ? (Border)stylesheet.Borders.ChildElements[(int)borderId] : null; + return new ExcelCellBordersStyle + { + LeftBorder = bordersStyle?.LeftBorder == null ? null : GetBorderStyle(bordersStyle.LeftBorder), + RightBorder = bordersStyle?.RightBorder == null ? null : GetBorderStyle(bordersStyle.RightBorder), + TopBorder = bordersStyle?.TopBorder == null ? null : GetBorderStyle(bordersStyle.TopBorder), + BottomBorder = bordersStyle?.BottomBorder == null ? null : GetBorderStyle(bordersStyle.BottomBorder) + }; + } - private ExcelCellNumberingFormat GetCellNumberingFormat(uint numberFormatId) - { - if (standardNumberingFormatsId.Contains(numberFormatId)) - return new ExcelCellNumberingFormat(numberFormatId); + private ExcelCellBorderStyle GetBorderStyle(BorderPropertiesType border) + { + return new ExcelCellBorderStyle + { + Color = ToExcelColor(border?.Color), + BorderType = border?.Style == null ? ExcelBorderType.None : ToExcelBorderType(border.Style) + }; + } - var numberFormat = (NumberingFormat)stylesheet?.NumberingFormats?.ChildElements - .FirstOrDefault(ce => ((NumberingFormat)ce)?.NumberFormatId != null && - ((NumberingFormat)ce).NumberFormatId!.Value == numberFormatId); - if (numberFormat?.FormatCode?.Value == null) - return null; + private static ExcelBorderType ToExcelBorderType(EnumValue borderStyle) + { + if (borderStyle.Value == BorderStyleValues.None) + return ExcelBorderType.None; + if (borderStyle.Value == BorderStyleValues.Thin) + return ExcelBorderType.Thin; + if (borderStyle.Value == BorderStyleValues.Medium) + return ExcelBorderType.Single; + if (borderStyle.Value == BorderStyleValues.Thick) + return ExcelBorderType.Bold; + if (borderStyle.Value == BorderStyleValues.Double) + return ExcelBorderType.Double; + throw new InvalidOperationException($"Unknown border type: {borderStyle}"); + } - return new ExcelCellNumberingFormat(numberFormat.NumberFormatId!.Value, numberFormat.FormatCode.Value); - } + private ExcelCellNumberingFormat GetCellNumberingFormat(uint numberFormatId) + { + if (standardNumberingFormatsId.Contains(numberFormatId)) + return new ExcelCellNumberingFormat(numberFormatId); - private ExcelCellFontStyle GetCellFontStyle(uint fontId) - { - var internalFont = stylesheet?.Fonts?.ChildElements.Count > fontId ? (Font)stylesheet.Fonts.ChildElements[(int)fontId] : null; - return new ExcelCellFontStyle - { - Bold = internalFont?.Bold != null, - Size = internalFont?.FontSize == null ? (int?)null : Convert.ToInt32((object)internalFont.FontSize?.Val?.Value), - Underlined = internalFont?.Underline != null, - Color = ToExcelColor(internalFont?.Color) - }; - } + var numberFormat = (NumberingFormat)stylesheet?.NumberingFormats?.ChildElements + .FirstOrDefault(ce => ((NumberingFormat)ce)?.NumberFormatId != null && + ((NumberingFormat)ce).NumberFormatId!.Value == numberFormatId); + if (numberFormat?.FormatCode?.Value == null) + return null; - private ExcelCellFillStyle GetCellFillStyle(uint fillId) - { - var fill = stylesheet?.Fills?.ChildElements.Count > fillId ? (Fill)stylesheet.Fills.ChildElements[(int)fillId] : null; - var color = ToExcelColor(fill?.PatternFill?.ForegroundColor); + return new ExcelCellNumberingFormat(numberFormat.NumberFormatId!.Value, numberFormat.FormatCode.Value); + } - if (color == null) - return null; + private ExcelCellFontStyle GetCellFontStyle(uint fontId) + { + var internalFont = stylesheet?.Fonts?.ChildElements.Count > fontId ? (Font)stylesheet.Fonts.ChildElements[(int)fontId] : null; + return new ExcelCellFontStyle + { + Bold = internalFont?.Bold != null, + Size = internalFont?.FontSize == null ? (int?)null : Convert.ToInt32((object)internalFont.FontSize?.Val?.Value), + Underlined = internalFont?.Underline != null, + Color = ToExcelColor(internalFont?.Color) + }; + } - return new ExcelCellFillStyle {Color = color}; - } + private ExcelCellFillStyle GetCellFillStyle(uint fillId) + { + var fill = stylesheet?.Fills?.ChildElements.Count > fillId ? (Fill)stylesheet.Fills.ChildElements[(int)fillId] : null; + var color = ToExcelColor(fill?.PatternFill?.ForegroundColor); - [CanBeNull] - private ExcelColor ToExcelColor([CanBeNull] ColorType color) - { - if (color == null) - return null; - if (color.Rgb?.HasValue == true) - { - return RgbStringToExcelColor(color.Rgb.Value!); - } - if (color.Theme?.HasValue == true) - { - var theme = color.Theme.Value; - var tint = color.Tint?.Value ?? 0; - return ThemeToExcelColor(theme, tint); - } + if (color == null) return null; - } - [CanBeNull] - private static ExcelColor RgbStringToExcelColor([NotNull] string hexRgbColor) + return new ExcelCellFillStyle {Color = color}; + } + + [CanBeNull] + private ExcelColor ToExcelColor([CanBeNull] ColorType color) + { + if (color == null) + return null; + if (color.Rgb?.HasValue == true) { - if (hexRgbColor.Length == 6) - hexRgbColor = "FF" + hexRgbColor; - return new ExcelColor(alpha : Convert.ToInt32(hexRgbColor.Substring(0, 2), 16), - red : Convert.ToInt32(hexRgbColor.Substring(2, 2), 16), - green : Convert.ToInt32(hexRgbColor.Substring(4, 2), 16), - blue : Convert.ToInt32(hexRgbColor.Substring(6, 2), 16)); + return RgbStringToExcelColor(color.Rgb.Value!); } - - [CanBeNull] - private ExcelColor ThemeToExcelColor(uint theme, double tint) + if (color.Theme?.HasValue == true) { - if (theme >= colorSchemeElements.Count) - throw new InvalidOperationException($"Theme with id '{theme}' not found"); - var color2Type = colorSchemeElements[(int)theme]; - var rgbColor = color2Type?.RgbColorModelHex?.Val?.Value ?? color2Type?.SystemColor?.LastColor?.Value; - if (rgbColor == null) - { - logger.Error("Failed to get rgbColor from theme"); - return null; - } - var hls = ColorConverter.RgbToHls(RgbStringToExcelColor(rgbColor)); - if (tint < 0) - hls.L = hls.L * (1.0 + tint); - else - hls.L = hls.L * (1.0 - tint) + tint; - return ColorConverter.HslToRgb(hls); + var theme = color.Theme.Value; + var tint = color.Tint?.Value ?? 0; + return ThemeToExcelColor(theme, tint); } + return null; + } + + [CanBeNull] + private static ExcelColor RgbStringToExcelColor([NotNull] string hexRgbColor) + { + if (hexRgbColor.Length == 6) + hexRgbColor = "FF" + hexRgbColor; + return new ExcelColor(alpha : Convert.ToInt32(hexRgbColor.Substring(0, 2), 16), + red : Convert.ToInt32(hexRgbColor.Substring(2, 2), 16), + green : Convert.ToInt32(hexRgbColor.Substring(4, 2), 16), + blue : Convert.ToInt32(hexRgbColor.Substring(6, 2), 16)); + } - private static AlignmentCacheItem Alignment(ExcelCellAlignment cellAlignment) + [CanBeNull] + private ExcelColor ThemeToExcelColor(uint theme, double tint) + { + if (theme >= colorSchemeElements.Count) + throw new InvalidOperationException($"Theme with id '{theme}' not found"); + var color2Type = colorSchemeElements[(int)theme]; + var rgbColor = color2Type?.RgbColorModelHex?.Val?.Value ?? color2Type?.SystemColor?.LastColor?.Value; + if (rgbColor == null) { - if (cellAlignment == null) - return null; - if (cellAlignment.HorizontalAlignment == ExcelHorizontalAlignment.Default && cellAlignment.VerticalAlignment == ExcelVerticalAlignment.Default && !cellAlignment.WrapText) - return null; - return new AlignmentCacheItem(cellAlignment); + logger.Error("Failed to get rgbColor from theme"); + return null; } + var hls = ColorConverter.RgbToHls(RgbStringToExcelColor(rgbColor)); + if (tint < 0) + hls.L = hls.L * (1.0 + tint); + else + hls.L = hls.L * (1.0 - tint) + tint; + return ColorConverter.HslToRgb(hls); + } - // standardNumberingFormatsId -- set of numbering formats that can be identified without format codes - // https://docs.microsoft.com/en-us/dotnet/api/documentformat.openxml.spreadsheet.numberingformat?view=openxml-2.8.1 - private static HashSet standardNumberingFormatsId = new HashSet {0, 1, 2, 3, 4, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 37, 38, 39, 40, 45, 46, 47, 48, 49}; - - private readonly Stylesheet stylesheet; - private readonly ILog logger; - private readonly ExcelDocumentNumberingFormats numberingFormats; - private readonly ExcelDocumentFillStyles fillStyles; - private readonly ExcelDocumentBordersStyles bordersStyles; - private readonly IExcelDocumentFontStyles fontStyles; - private readonly List colorSchemeElements; - private readonly IDictionary cache; - private readonly IDictionary inverseCache; + private static AlignmentCacheItem Alignment(ExcelCellAlignment cellAlignment) + { + if (cellAlignment == null) + return null; + if (cellAlignment.HorizontalAlignment == ExcelHorizontalAlignment.Default && cellAlignment.VerticalAlignment == ExcelVerticalAlignment.Default && !cellAlignment.WrapText) + return null; + return new AlignmentCacheItem(cellAlignment); } + + // standardNumberingFormatsId -- set of numbering formats that can be identified without format codes + // https://docs.microsoft.com/en-us/dotnet/api/documentformat.openxml.spreadsheet.numberingformat?view=openxml-2.8.1 + private static HashSet standardNumberingFormatsId = new HashSet {0, 1, 2, 3, 4, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 37, 38, 39, 40, 45, 46, 47, 48, 49}; + + private readonly Stylesheet stylesheet; + private readonly ILog logger; + private readonly ExcelDocumentNumberingFormats numberingFormats; + private readonly ExcelDocumentFillStyles fillStyles; + private readonly ExcelDocumentBordersStyles bordersStyles; + private readonly IExcelDocumentFontStyles fontStyles; + private readonly List colorSchemeElements; + private readonly IDictionary cache; + private readonly IDictionary inverseCache; } \ No newline at end of file diff --git a/Excel.TemplateEngine/FileGenerating/DataTypes/ExcelHorizontalAlignment.cs b/Excel.TemplateEngine/FileGenerating/DataTypes/ExcelHorizontalAlignment.cs index abb230b..8da453d 100644 --- a/Excel.TemplateEngine/FileGenerating/DataTypes/ExcelHorizontalAlignment.cs +++ b/Excel.TemplateEngine/FileGenerating/DataTypes/ExcelHorizontalAlignment.cs @@ -1,10 +1,10 @@ -namespace SkbKontur.Excel.TemplateEngine.FileGenerating.DataTypes +namespace SkbKontur.Excel.TemplateEngine.FileGenerating.DataTypes; + +public enum ExcelHorizontalAlignment { - public enum ExcelHorizontalAlignment - { - Default, - Left, - Center, - Right - } + Default, + Left, + Center, + Right, + Fill, } \ No newline at end of file