WordML in Reporting Services
Although Reporting Services is almost 22 months old, I haven't found any pure render extension yet (please comment on this[:-*]). Many people ask me 'how can I export reports in Microsoft Word format?', and I usually redirect them to our BOL. But after looking up in the RS documentation, I realized that it is not as straighforward as expected, so I will try to simplify it.
ReportingService.Render Method
You can find easily this method in the documentation , it explain how to render a built report programmatically. In our sample the most important parameters are:
- Format, Reporting Services allows you to export the report from the IF to any format configure as rendering extension. So w can export by default to: XML, CSV, IMAGE (Different image format here), PDF, HTML4.0, HTML3.2, MHTML, EXCEL and HTMLOWC. We will choose XML.
- DeviceInfo, it is a XML string that contains the necessary information for the rendering extension chosen above.
Then we can take a closer look to the XML Device Information Settings.
Here we have (XSLT, MIMEType, UseFormattedValues, Indented, OmitSchema, Encoding, FileExtension, Schema), I will comment the first one XSLT. It will be the path in the report server namespace of an XSLT to apply to the XML file. This means that you can upload a XSL file, and include its path here.
The approach I'm following to create Microsoft Word Format, is based on WordML Format, and you can use:
- Microsoft Office Word 2003
- Word Viewer 2003 (standalone application)
- Word 2003: XML Viewer (Internet Explorer)
- Any other application that consumes WordML.
to see the final doc.
Is there an easy way?
Well, you can follow the sample and create an application that creates a WordML file....or you can use Reporting Services URL Access and do it in a simple way.
So we follow these steps:
- Create a report based on AdventureWorks2000 database, with Data Source (Check it).
- Deploy them to the ReportServer
- Create the XSLT to convert from XML (RS rendering) format to WordML format (Check it).
- Uploaded the file transform01.xsl to MyXSLT folder
- Create a URL Access with all the information:
- https://localhost/ReportServer?
- /RSDemos/AdW2KProducts
- &rs:Format=XML&rs:Command=Render
- &rc:XSLT=/MyXSLT/transform01.xsl
- &rc:FileExtension=doc (you may try &rc:FileExtension=xml too due to the Word PI)
- &Category=22
- Access the URL (Check it).
And that's it, we have our WordML report.
We could create RTF documents following the same pattern.
What about better documentation
Yes, I know BOL RS could be better (Eyerthing can improve!), and that is the reason we heard from customers and improve the documentation (and improve the searching [;)])!
Check the MSDN / MSDN2 docs:
- RS 2000: Designing for XML Output RS 2005: Designing for XML Output
- RS 2000: Elements and Attributes in XML Rendering RS 2005: Elements and Attributes in XML Rendering
- RS 2000: Applying Transformations to XML Output RS 2005: Applying Transformations to XML Output
HTML Report
WordML Report
BOL, RS, WordML, XSLT, URL, IF, RTF, XML, PDF, CSV, MSDN
[Updated links MSDN / MSDN2 18-Oct-2005]
[Updated text and transform01 22-Mar-2006]
Comments
- Anonymous
March 21, 2006
I have updated the transform01.xsl to include the Word PI and alternative extension for the final export.
Thanks to jagbarcelo to figure it out!. - Anonymous
September 19, 2006
It is nice to see your ideas across the web :) jbarcelo has a great article about this sample implemented for their needs.
Check it out!
http://jagbarcelo.blogspot.com/2006/07/reporting-services-ms-word-format-doc.html - Anonymous
April 08, 2007
The comment has been removed - Anonymous
April 19, 2013
Is it possible to render a ssrs report in msword format?