Jan 31, 2015 01:41 PM|Boris Pavlovic|LINK
Word automation on any kind of server will cause troubles sooner or later, and Microsoft in its KB 257757 (http://support.microsoft.com/kb/257757) advises not to use it.
What you need is OpenXML based solution. Now to start OpenXML from scratch is something you would want to do only if you have plenty of time and don't mind struggling with tons of specifications and trial and error approaches as you will have hard times
finding suitable answers to your questions.
In my opinion, going with some 3rd party tool that has OpenXML support is the only viable solution: Aspose and Windward are two of the most known. I have experience with Docentric Toolkit, which is really simple to use, though you will need a developer license.
But it does not require any run-time server license.
To integrate Word document generation into ASP.NET you would follow these steps:
Below is a sample code which reads customers from France from Northwind database and merges them twith the Word template document to generate new Word document:
static void Main(string args)
List<Customer> custList = new List<Customer>();
using (var ctx = new NorthwindEntities1())
custList = ctx.Customers.Where(q => q.Country == "France").ToList();
string templateName = @"c:\temp\Customers.docx";
string generatedDocument = @"c:\temp\Customers_result.docx";
DocumentGenerator dg = new DocumentGenerator(custList);
DocumentGenerationResult result = dg.GenerateDocument(templateName, generatedDocument);
catch (Exception ex)
// wait for the input to terminate the application
Console.WriteLine("Press Enter to exit...");
As you can see the code is super simple. The result is a plain Word document (docx). You don't need Office installed on a server and document generation is very fast.