C# to replace strings of text in a docx

2020-07-10 10:13发布

问题:

Using C#, is there a good way to find and replace a text string in a docx file without having word installed on that machine?

回答1:

Yes, using Open XML. Here's an article which addresses your specific question: Creating a Simple Search and Replace Utility for Word 2007 Open XML Format Documents



回答2:

You may also try Aspose.Words for .NET in order to find and replace text in Word document. This component doesn't require MS Office to be installed. The API is quite simple and easy to use and implement.

Disclosure: I work as developer evangelist at Aspose.