Now and then I encounter forum questions in the style of the following:
I have a report with a title. When rendered through the Report Manager and when exported to PDF, I want it to render as normal. However, when exported to Excel I do not want to get the title. How can I hide it?
Because I don’t like re-inventing the wheel each time I decided to write a blog post about it.
As of SQL Server 2008 R2, we’ve got a built-in global field that can help us out. This field is called Globals!RenderFormat. It has two properties: Name and IsInteractive. Name represents the unique name that indicates the chosen renderer, and IsInteractive indicates whether or not the chosen report format is, well, interactive.
Depending on the renderer, the values of the properties differ. To be able to use the variable in an expression, we need to know its values for each rendering format. Here’s the list of different possibilities:
| Renderer | RenderFormat.Name | RenderFormat.IsInteractive |
| Preview in BIDS or rendered through Report Manager | RPL | True |
| XML file with report data | XML | False |
| CSV (comma delimited) | CSV | False |
| TIFF file or Print button | IMAGE | False |
| False | ||
| MHTML (web archive) | MHTML | True |
| Excel | EXCEL | False |
| Word | WORD | False |
If these names for RenderFormat look familiar to you, you’re probably right. Have a look at the rsreportserver.config file in the C:\Program Files\Microsoft SQL Server\MSRS10_50.SQL2008R2\Reporting Services\ReportServer folder. Note that you may need to adapt the folder to your specific settings. In my case my instance is called “SQL2008R2”. Near the bottom of that configuration file you can find the <Render> node, located under <Extensions>. The names that you see there are those used by the RenderFormat.Name property.
Now that we know what values to test on, let’s get started.
If we get back to the example of hiding a title, or textbox, when exporting to Excel, here’s what needs to happen. Locate the Hidden property of the textbox that you want to hide, and give it the following expression:
=IIF(Globals!RenderFormat.Name = "EXCEL", True, False)
What we’re saying here is: if the RenderFormat is EXCEL, then the Hidden property should be set to True. Which results in a hidden textbox whenever the report is exported to Excel!
As Erik pointed out in the comments, in this particular case you don’t need the IIF() statement. The result of the expression results in True when the expected value should be True, and False when False is expected.
As a quick note: when building your expression through the expression builder, you’ll notice that the Intellisense doesn’t know the new RenderFormat field yet. Do not worry about that, just continue typing and ignore any errors being indicated. If you use the syntax as I highlighted above, it will work! Well, unless you’re running an earlier version than SQL Server 2008 R2 of course. In that case it won’t work.

In contradiction to the Intellisense, the bottom part of the expression builder screen has been updated to show the new properties. So if you don’t remember the syntax, you can just locate the field in the Built-in Fields category and give it a good double-click.
Of course, the Excel example in this post is just one of many possibilities that this new field offers. Is your company environment-friendly and does it want to prevent wasting paper? Now it’s possible, just hide that 50-pages long table when the report is being rendered for print!
Have fun!
Valentino.
References
Globals!RenderFormat aka Renderer Dependent Report Layout by Robert Bruckner




Yes, I’m happy to announce that I have passed the 70-451 exam. For those who are not familiar with the numbers, it’s the exam to get the MCITP Database Developer 2008 certificate.




