One of the design principles of the Reporting Services platform is that you author a report once, and it then renders to all interactive and export formats with as much fidelity as possible (and enabled by the underlying export format). You don’t need to worry how certain report items and style settings translate to HTML vs. Word vs. Excel vs. PDF. While consistent report layout and style rendering across output formats is often desired, there are reporting situations where you desire to make rendering format dependent decisions as well. Reporting Services 2008 R2 introduces the ability to make layout and format decisions based on the rendering format.
You can access the name of the rendering extension as registered in the configuration file (=Globals!RenderFormat.Name). Furthermore, a Boolean flag (=Globals!RenderFormat.IsInteractive) determines whether a rendering extension is an interactive renderer, i.e. not an export format. Preview (GDI/Winforms) and HTML viewing are considered interactive renderers.
Both of these new global variables can be used in layout and formatting expressions (in other words, expressions evaluated as part of on-demand report processing). Note that references to Globals!RenderFormat properties cannot be used in data processing related expressions (i.e. grouping, sorting, filtering, aggregation, report/group variables, subreport parameters), because those expressions are only calculated once unrelated to a specific rendering format.
So for which reporting scenarios could this be useful?
- Use complex formatting and interactivity for on-screen display, but optimize for Excel export and post-processing with a more data oriented view.
- Print: add/omit text disclaimers, logos, background images, etc.
- PDF/Excel/Word: dynamically disable hyperlinks when report is exported
- TIFF/Print: define a particular color chart palette for all rendering formats, but use an optimized grayscale palette when using TIFF for fax, or printing
The screenshot below shows the Excel and HTML view of the same report side-by-side (the report is derived from the Product Catalog sample report). All you need to try this yourself is the AdventureWorks2008 sample database (download), and the report from the attachment of this posting (download), and/or read more details and specific step-by-step instruction in the following book on pages 454-459.
In some scenarios, just distinguishing between interactive and export formats is sufficient (utilizing =Globals!RenderFormat.IsInteractive). If in your particular situation you have to make decisions based on the actual type of rendering format, you have to write your expression using the exact, case-sensitive name of the rendering extension as registered in RSReportServer.config / RSReportDesigner.config.
Reporting Services built-in rendering extension names include: "WORD", "EXCEL", "PDF", "MHTML", "IMAGE" (includes TIFF, Print). Note that interactive viewing in preview or report manager uses the "RPL" renderer.
The screenshot below shows a typical usage example of setting a Visibility.Hidden expression to =(Globals!RenderFormat.IsInteractive = "EXCEL")to hide a particular reportitem when exporting to Excel.
Final thoughts: for data rendering specific behavior (XML, CSV, ATOM data feeds) I recommend to use the DataElementOutput and DataElementName properties available on reportitems and groups instead of using dynamic visibility and rendering behavior based on the RenderFormat global variable.