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
306 stars 107 forks source link

Allow end users to define default styles #80

Closed DynaSpan closed 3 years ago

DynaSpan commented 3 years ago

This PR allows end users to define default styles for diverse items:

This can be useful if we're using WYSIWYG editors, where changing classes of items can not be simple.

Breaking changes: The fields DefaultParagraphStyle and DefaultStyle have been removed from HtmlDocumentStyle.cs.

onizet commented 3 years ago

Normally, I recommend to define your document by editing the predefined Word-styles and then, push the converted HTML into that document. Another way is to rely on CSS class that match Word custom-styles.

I am curious why these 2 above solutions didn't give you satisfaction and you need more control?

DynaSpan commented 3 years ago

In my specific use-case, I generate a Word document from a lot of HTML & pre-existing Word documents.

The HTML is generated from WYSIWYG editors, which don't always have the option to define default classes (e.g. for tables). My Word documents use a base style document, on which all content is copied.

In my example, this base style document also has a table style. However, this style is not named "TableGrid" as it would mess with tables from pre-existing Word documents that are merged into the new document.

Therefore, it would be nice if we could specify default styles for items, such as a table.

onizet commented 3 years ago

Ok sound good to me. Thanks for the explanation, I will update the wiki accordingly