I'm using .Net Core 2.1 on Ubuntu Linux (16.04), and using the Xceed DocX library for .Net. I'm aware the DocX Library targets .Net Framework 4.0/4.6 and so there may be compatibility issues there, however it at least works part way so I assume I'm missing something out.
I can create a .docx file (see below code), however no matter how much content I insert the word doc is always generated as empty.
When I check the document text contents using console output after the document has been saved, it shows the content is there.
I presume there must be an issue with how I'm writing the file, however it's not clear at all from the Xceed code source or from extensive searches regarding .Net how this should be done.
How do I get the document content to be written?
Similar question that wasn't much help: Xceed Docx returns blank document
using System;
using System.IO;
using Xceed.Words.NET;
namespace docx_generator
{
class Program
{
static void Main(string[] args)
{
var filename = "../../Documents/Test.docx";
using(DocX doc = DocX.Create(filename))
{
var p = doc.InsertParagraph("A very basic title");
doc.Save();
Console.Write(doc.Text);
// > A very basic title
}
}
}
}