From 33abda11f446871e6d94738903be98257e5beff0 Mon Sep 17 00:00:00 2001 From: Joe S <2297233+Tranquilite0@users.noreply.github.com> Date: Fri, 4 Apr 2025 12:56:31 -0600 Subject: [PATCH 1/2] Fix table borders being removed Fix table borders being removed even when the specified word table style has borders. --- src/Html2OpenXml/Expressions/Table/TableExpression.cs | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/Html2OpenXml/Expressions/Table/TableExpression.cs b/src/Html2OpenXml/Expressions/Table/TableExpression.cs index cd6d8e26..96a569d7 100644 --- a/src/Html2OpenXml/Expressions/Table/TableExpression.cs +++ b/src/Html2OpenXml/Expressions/Table/TableExpression.cs @@ -199,8 +199,6 @@ protected override void ComposeStyles (ParsingContext context) } var align = Converter.ToParagraphAlign(tableNode.GetAttribute("align")); - if (!align.HasValue) - align = Converter.ToParagraphAlign(styleAttributes["justify-self"]); if (align.HasValue) tableProperties.TableJustification = new() { Val = align.Value.ToTableRowAlignment() }; @@ -244,8 +242,9 @@ protected override void ComposeStyles (ParsingContext context) tableProperties.TableBorders = tableBorders; } - // is the border=0? If so, we remove the border regardless the style in use - else if (tableNode.Border == 0) + // is the border=0? If so, we remove the border regardless the style in use + // but only remove border if the html style border was set, otherwise leave the border style as-is. + else if (!styleBorder.IsEmpty && tableNode.Border == 0) { tableProperties.TableBorders = new TableBorders() { TopBorder = new TopBorder { Val = BorderValues.None }, From 316ae75556960ebe8fd84ac4a8575a838d6df64a Mon Sep 17 00:00:00 2001 From: Joe S <2297233+Tranquilite0@users.noreply.github.com> Date: Thu, 10 Apr 2025 13:58:45 -0600 Subject: [PATCH 2/2] Revert inadvertent change. --- src/Html2OpenXml/Expressions/Table/TableExpression.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/Html2OpenXml/Expressions/Table/TableExpression.cs b/src/Html2OpenXml/Expressions/Table/TableExpression.cs index 96a569d7..2bc9d905 100644 --- a/src/Html2OpenXml/Expressions/Table/TableExpression.cs +++ b/src/Html2OpenXml/Expressions/Table/TableExpression.cs @@ -199,6 +199,8 @@ protected override void ComposeStyles (ParsingContext context) } var align = Converter.ToParagraphAlign(tableNode.GetAttribute("align")); + if (!align.HasValue) + align = Converter.ToParagraphAlign(styleAttributes["justify-self"]); if (align.HasValue) tableProperties.TableJustification = new() { Val = align.Value.ToTableRowAlignment() }; @@ -242,7 +244,7 @@ protected override void ComposeStyles (ParsingContext context) tableProperties.TableBorders = tableBorders; } - // is the border=0? If so, we remove the border regardless the style in use + // is the border=0? If so, we remove the border regardless the style in use // but only remove border if the html style border was set, otherwise leave the border style as-is. else if (!styleBorder.IsEmpty && tableNode.Border == 0) {