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.
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.
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:
- &rc:FileExtension=doc (you may try &rc:FileExtension=xml too due to the Word PI)
- 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
[Updated links MSDN / MSDN2 18-Oct-2005]
[Updated text and transform01 22-Mar-2006]