Project Description
ElfDoc enables you to create word documents from templates, using open xml.
Step 0 : install open xml sdk.
http://www.microsoft.com/download/en/details.aspx?id=5124
Step 1 : Create a model.
e.g.
public class Person{ public string Surname{get;set;} }
Open Word 2010, enable the developer tab, add a content control, set title and tag properties of the content control to a property name from your model e.g. Surname.
Step 3 : Create word file by applying the template to the model i.e. model * MyTemplate.docx -> output.docx
var model= new Person{Surname="Smith"}; var documentConvolution = new DocumentConvolution{ Source = "MyTemplate.docx" , Target = "Output.docx" } ; documentConvolution.Convolve(model);
You should now have a word document on the disc, called Output.docx with the text 'Smith' in the document.
Step 4 : Relax, drink tea.
Contribute, improve, and make suggestions for ElfDoc.