Templating Word Documents in C#
- by NullGeo
I was wondering if there is a library out there such that it could give me the ability to fill in word templates with custom values.
For example: Following could be the content of the Word Document
{Address}
{PhoneNumber}
Hello {Name}, How are you doing?
In C# I would like to do something like this to replace all the placeholders in the Word document:
using(WordDocument doc = WordDocument.Load("Mail.docx")){
var person = new {Name = "John Smith", Address="42 Wallaby Way, Sydney", PhoneNumber="555-555-5555"};
doc.Template(person);
doc.Print();
}
The resulting document would look like this:
42 Wallaby Way, Sydney
555-555-5555
Hello John Smith, How are you doing?
Any libraries out there (preferably free) that let's me do this?
Edit: I am not asking you to find anything that let's me do this. If that was the case, I would do a Google search by myself. Honestly, all I am asking is "has anybody used a library in the past to do this exact thing."