I'm working on a simple document merge. Wanted to find some strings and replace it with another string (Outside table).
So here is the issue, when i try to use TextReplacer.SearchAndReplace
after accessing table using var table = wordDoc.MainDocumentPart.Document.Body.Elements<DocumentFormat.OpenXml.Wordprocessing.Table>();
then SearchAndReplace
is not working. Don't know what is the issue.
eg code:
private static async Task MergeDoc(WordprocessingDocument wordDoc) {
var table = wordDoc.MainDocumentPart.Document.Body.Elements<DocumentFormat.OpenXml.Wordprocessing.Table>();
TextReplacer.SearchAndReplace(wordDoc, "string to replace", "value", true);
}
If I remove the table
variable which actually a reference to the table from word document, then SearchAndReplace is working