Export list to Word
-
22-10-2019 - |
Question
Is there a way to easily export a list to Microsoft Word 2010 from SharePoint 2010 via a button on the page? We'd like to have the data plugged into a Word template so the list values get formatted/placed correctly. We don't mind creating a custom web part if that's what it requires.
Thank you for your guidance.
Solution
It is very easy to create a control or a web part and place it on the page. The control would contain a button with code behind that uses OpenXML to generate the Word document.
I've done similar things and it's very easy. Just create a Word document using Word and format it as you like, then use the Document Reflector from the OpenXML SDK v2+ to generate a C# class that generates a document. Copy that class (and reference the OpenXML assemblies) and modify to suit your needs.