I am working on an application that uses Microsoft Word files as a template to generate documents. I use Merge fields to get data into my documents.
A SimpleField
can have its result set fairly easy:
SimpleField f = doc.MainDocumentPart.Document.Body.Descendants<SimpleField>().First();
f.RemoveAllChildren();
f.Append(new Run(new Text("somevalue")));
but, when a field is styled in Word, it is save as a FieldChar
, which is a little more complex. The above method doesn't work there, because the result is not a child, but a sibling.
So, basically the question is: how can I set the result of a field (any type) using Open XML SDK ?