From f0663a51cb82aba6750f93f6c4d4fa7c320a9f67 Mon Sep 17 00:00:00 2001 From: Iain McAndrew Date: Fri, 19 Jul 2024 19:49:23 +0100 Subject: [PATCH] FindAndReplaceText will now also work for tables within a documents header and footer --- ooxml/XWPF/Usermodel/XWPFDocument.cs | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/ooxml/XWPF/Usermodel/XWPFDocument.cs b/ooxml/XWPF/Usermodel/XWPFDocument.cs index abda4ba16..9be63d126 100644 --- a/ooxml/XWPF/Usermodel/XWPFDocument.cs +++ b/ooxml/XWPF/Usermodel/XWPFDocument.cs @@ -1958,13 +1958,22 @@ public void FindAndReplaceText(string oldValue, string newValue) { FindAndReplaceTextInParagraph(paragraph, oldValue, newValue); } + foreach(var table in footer.Tables) + { + FindAndReplaceTextInTable(table, oldValue, newValue); + } } + foreach (var header in this.HeaderList) { foreach (var paragraph in header.Paragraphs) { FindAndReplaceTextInParagraph(paragraph, oldValue, newValue); } + foreach(var table in header.Tables) + { + FindAndReplaceTextInTable(table, oldValue, newValue); + } } } public void Dispose()