Friday 4 April 2008

Reporting Services Export formats - ASCII CSV and more


It seem Reporting Services is quite extensible. After much discussion around how we can provide a decent way to post-process a CSV file generated by an RS report, we found that we can add endless export formats (scary!) to a report.
Typically, out-of-the-box we have a few, namely CSV (unicode), PDF, etc. So we needed CSV in ASCII, with no headers. Umm! stumped for a bit, then the general problem-solver goes into motion and we come up with standard ideas of how and what more. But wait! There is simple answer there.



  1. Open your C:\Program Files\Microsoft SQL Server\\Reporting Services\ReportServer\rsreportserver.config

  2. Scroll down to <Render> section and you will see -
     <Render>
    <Extension Name="XML" Type="Microsoft.ReportingServices.Rendering.XmlDataRenderer.XmlDataReport,Microsoft.ReportingServices.XmlRendering"/>
    <Extension Name="NULL" Type="Microsoft.ReportingServices.Rendering.NullRenderer.NullReport,Microsoft.ReportingServices.NullRendering" Visible="false"/>
    <Extension Name="CSV" Type="Microsoft.ReportingServices.Rendering.CsvRenderer.CsvReport,Microsoft.ReportingServices.CsvRendering"/>
    <Extension Name="IMAGE" Type="Microsoft.ReportingServices.Rendering.ImageRenderer.ImageReport,Microsoft.ReportingServices.ImageRendering"/>
    <Extension Name="PDF" Type="Microsoft.ReportingServices.Rendering.ImageRenderer.PdfReport,Microsoft.ReportingServices.ImageRendering"/>
    <Extension Name="RGDI" Type="Microsoft.ReportingServices.Rendering.ImageRenderer.RemoteGdiReport,Microsoft.ReportingServices.ImageRendering" Visible="false" LogAllExecutionRequests="false"/>
    <Extension Name="HTML4.0" Type="Microsoft.ReportingServices.Rendering.HtmlRenderer.Html40RenderingExtension,Microsoft.ReportingServices.HtmlRendering" Visible="false" LogAllExecutionRequests="false"/>
    <Extension Name="HTML3.2" Type="Microsoft.ReportingServices.Rendering.HtmlRenderer.Html32RenderingExtension,Microsoft.ReportingServices.HtmlRendering" Visible="false"/>
    <Extension Name="MHTML" Type="Microsoft.ReportingServices.Rendering.HtmlRenderer.MHtmlRenderingExtension,Microsoft.ReportingServices.HtmlRendering"/>
    <Extension Name="EXCEL" Type="Microsoft.ReportingServices.Rendering.ExcelRenderer.ExcelRenderer,Microsoft.ReportingServices.ExcelRendering"/>
    </Render>

  3. That's where the 'pluggability' is at. Each extension has a Renderer type. For simple stuff, like mine, just copy the CSV element and paste it back in. Rename the Name attribute to "CSV2".

  4. Add overrides for the name that is displayed in the report dropdown menu - see CSV(ASCII)
  5. And add DeviceInformationSettings in xml - the whole thing should look like..
    <Extension
    Name="CSV2" Type="Microsoft.ReportingServices.Rendering.CsvRenderer.CsvReport,Microsoft.ReportingServices.CsvRendering>
    <OverrideNames>
    <Name Language="en-UK">CSV(ASCII)</Name>
    </OverrideNames>
    <Configuration>
    <DeviceInfo>
    <Encoding>ASCII</Encoding>
    </DeviceInfo>
    </Configuration>
    </Extension>
  6. Save it back (hope you got a backup copy of the config just in case)
  7. Go to IIS (Control Panels/Admin..Tools/Internet Inf...), find ReportServer under Application Pools and recycle the pool ( so that the next report picks up the new changes
  8. Done
If you need to write some funkier renderers, then consult MSDN. They have a standard api for it now.