onizet / html2openxml

Html2OpenXml is a small .Net library that convert simple or advanced HTML to plain OpenXml components. This program has started in 2009, initially to convert user's comments from SharePoint to Word.
MIT License
297 stars 106 forks source link

Update HtmlDocumentStyle.cs #117

Closed gilbertogwa closed 1 year ago

gilbertogwa commented 2 years ago

Code to avoid "An item with the same key has already been added" error.

onizet commented 1 year ago

Thank you very much!

JohnH-Work commented 1 year ago

@onizet FYI. This PR breaks any Word documents where you are using standard headings. I noticed that when I switched from the latest NuGet package to the code on the dev branch all my headings were using the default styles.

By default, Word uses styleId="Heading1" and name="heading 1" for the header style. All header paragraphs will therefore reference "Heading1". The code in this PR updates the styleId of every Heading {n} style to the name, which breaks the link from the heading paragraph to the style.