I have a docx document that I want to modify via OpenXML SDK. This document has a table with bookmarks in its cells. The cells have specific font settings, let's say it's Times New Roman, 14pt. When I try to insert some text like this:
public void ReplaceBookmark(string bookMarkName, string text)
{
var bookmarkStart =
_document.MainDocumentPart.RootElement.Descendants<BookmarkStart>()
.Where(p => p.Name == bookMarkName)
.FirstOrDefault();
if (bookmarkStart == null)
return;
bookmarkStart.InsertAfterSelf(new Run(new Text(text)));
}
the texts is inserted, but its style is set Calibri, 11pt (the default style). How can I insert the text so that the font settings are preserved? The important thing is that i shouldn't define any style settings in the code, but use those of the original document instead.
Thanks.