I\'m using this method for generating docx file:
public static void CreateDocument(string documentFileName, string text)
{
using (Wordproces
You cannot just insert the HTML content into a "document.xml", this part expects only a WordprocessingML content so you'll have to convert that HTML into WordprocessingML, see this.
Another thing that you could use is altChunk element, with it you would be able to place a HTML file inside your DOCX file and then reference that HTML content on some specific place inside your document, see this.
Last as an alternative, with GemBox.Document library you could accomplish exactly what you want, see the following:
public static void CreateDocument(string documentFileName, string text)
{
DocumentModel document = new DocumentModel();
document.Content.LoadText(text, LoadOptions.HtmlDefault);
document.Save(documentFileName);
}
Or you could actually straightforwardly convert a HTML content into a DOCX file:
public static void Convert(string documentFileName, string htmlText)
{
HtmlLoadOptions options = LoadOptions.HtmlDefault;
using (var htmlStream = new MemoryStream(options.Encoding.GetBytes(htmlText)))
DocumentModel.Load(htmlStream, options)
.Save(documentFileName);
}