Web Service to Generate Word Documents

I’m just starting to work on a Web Service that will generate Word 2007 documents from a set of templates.  The inputs will be data from a SharePoint list. (More on that part of it when I get there.)

As I began setting up the Web Service, I realized that the System.IO.Packaging and Microsoft.Office.DocumentFormat.OpenXml.Packaging assemblies don’t seem to be available to add as references if the project is a Web Service.  If your project is a Windows application, they are.

I found the solution in a couple of great articles by Erika Ehrli at Microsoft: Building Server-Side Document Generation Solutions Using the Open XML Object Model, Part 1 and Part 2.

I had already downloaded and installed the assemblies:

Then I needed to manually add the references:

  • local_drive:\Program Files\Reference Assemblies\Microsoft\Framework\v3.0\WindowsBase.dll
  • local_drive:\Program Files\2007 Office System Developer Resources\OpenXMLSDK\1.0.0531\lib\Microsoft.Office.DocumentFormat.OpenXml.dll

Finally, I added the following code to web.config:

Have a thought or opinion?