diff --git a/ooxml/XWPF/Usermodel/XWPFDocument.cs b/ooxml/XWPF/Usermodel/XWPFDocument.cs index 7d57cdb26..c1c6977e1 100644 --- a/ooxml/XWPF/Usermodel/XWPFDocument.cs +++ b/ooxml/XWPF/Usermodel/XWPFDocument.cs @@ -1921,6 +1921,25 @@ private void FindAndReplaceTextInParagraph(XWPFParagraph paragraph, string oldVa } } } + + private void FindAndReplaceTextInTable(XWPFTable table, string oldValue, string newValue) + { + foreach (var row in table.Rows) + { + foreach (var cell in row.GetTableCells()) + { + foreach (var innerTable in cell.Tables) + { + FindAndReplaceTextInTable(innerTable, oldValue, newValue); + } + foreach (var paragraph in cell.Paragraphs) + { + FindAndReplaceTextInParagraph(paragraph, oldValue, newValue); + } + } + } + } + public void FindAndReplaceText(string oldValue, string newValue) { foreach (var paragraph in this.Paragraphs) @@ -1930,17 +1949,9 @@ public void FindAndReplaceText(string oldValue, string newValue) foreach (var table in this.Tables) { - foreach (var row in table.Rows) - { - foreach (var cell in row.GetTableCells()) - { - foreach (var paragraph in cell.Paragraphs) - { - FindAndReplaceTextInParagraph(paragraph, oldValue, newValue); - } - } - } + FindAndReplaceTextInTable(table, oldValue, newValue); } + foreach (var footer in this.FooterList) { foreach (var paragraph in footer.Paragraphs)