Skip to content

Conversation

@Tranquilite0
Copy link
Contributor

I noticed that the table styles in my template word doc were having their borders removed when being converted to openxml. This fix changes things to only remove borders if the border html style was set.

Fix table borders being removed even when the specified word table style has borders.
@onizet
Copy link
Owner

onizet commented Apr 10, 2025

Can you please paste some reproductible html snippets? Just for my understanding

@Tranquilite0
Copy link
Contributor Author

  1. Create a template Word Document and insert a table using the Table Grid 1 Light document style.
    • The exact table style used doesn't matter as long as it has borders.
  2. Convert the following HTML which uses the same table style and insert it into the document
<html>
    <head>
        <title></title>
    </head>
    <body>
        <p>This Table is inserted from HTML. It uses the same DOCX table style, but the border has been stripped.</p>
        <table class="GridTable1Light">
            <tr><td>One</td><td>Two</td></tr>
            <tr><td>Three</td><td>Four</td></tr>
        </table>
    </body>
</html>
  1. Note that the inserted table does not have any borders despite the style having borders specified:
    before
  2. After my fix it will have the same borders as the style:
    after

I feel like borders in Word Table styles should be respected.

The templates I have been using have a mix of table styles with and without borders, so postprocessing the document to add table borders back in is not trivial.

@onizet
Copy link
Owner

onizet commented Apr 10, 2025

Good spot, it's a nice improvement. Thank you for the explanation, it's much easier for me to understand

@sonarqubecloud
Copy link

@onizet onizet merged commit d55a00d into onizet:dev Apr 10, 2025
1 of 3 checks passed
@onizet onizet mentioned this pull request Apr 24, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants