I'm trying to insert text into Bookmarks
in an OpenXML .docx file, but it's inserting a new line after each Paragraph
. How can I prevent this?
e.g.:
I add the text to the document by finding the Bookmarks
with the following:
var bmk= body.Descendants<BookmarkStart>().FirstOrDefault(xx => xx.Name == "myBMK");
var parent = bmk.Parent;
parent.InsertBeforeSelf(GetText("DaveCompany"));
where GetText
is defined as:
public static Paragraph GetText(string cellText)
{
var run = new Run(new Text(cellText));
return new Paragraph(run);
}
I've tried stripping the text out of a Paragraph
, e.g.
parent.InsertBeforeSelf(new Run(new Text("DaveCompany")));
but that produced an invalid document.
How can I prevent the new line from being inserted?