Skip to content

How to find and replace ALL text in Word Documents with NPOI? #1186

Closed Answered by adamfisher
adamfisher asked this question in Q&A
Discussion options

You must be logged in to vote

I ended up modifying my extension method to process the tables contained in the headers and footers since that's where most of the replacements needed to happen in my case. As for detecting is a change was made, I use a hash of the document text so I know whether the document changed.

public static class XwpfDocumentExtensionMethods
{
	/// <summary>
	/// Performs find and replace on a Word document. 
	/// </summary>
	/// <param name="document">The Word document.</param>
	/// <param name="replacementValues">The mapping of values to be replaced within the document.</param>
	/// <returns>True if a value was replaced in the file, false otherwise.</returns>
	public static bool FindAndReplaceVa…

Replies: 3 comments 3 replies

Comment options

You must be logged in to vote
1 reply
@tonyqus
Comment options

Comment options

You must be logged in to vote
2 replies
@tonyqus
Comment options

@adamfisher
Comment options

Comment options

You must be logged in to vote
0 replies
Answer selected by adamfisher
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants