SSRS Possible to toggle Header visibility based on export type? 2008-R2

Jay picture Jay · Oct 28, 2016 · Viewed 7.6k times · Source

I'm familiar with dynamically showing/hiding other report objects (textboxes/tablix/columns etc...) based on a variable or parameter value - but is there a way to do this with the header? I don't see any "visibility" tab on the header object to set an expression.

Further more, is there a way to do hide the header based on the export style. For example, I want to show the header when exported to PDF, but want to hide it when exporting to XLS (to prevent cell merging).

I've seen examples of when the "header" is replaced by a "rectangle" which can be toggled. I've also seen articles refering to =Globals!RenderFormat.IsInteractive = “EXCEL”), but I don't know where that is set? On a server config file? Is there a way to have it done just for that one specific rdl report file?

Thanks in advance!

Answer

grafgenerator picture grafgenerator · Oct 28, 2016

Answering your questions:

Is there way to dynamically show/hide the header - no. Unfortunately, you can't set visibility for whole header/footer in RDL reports.

Is there way to hide the header based on the export style - not quite. As I stated, you can't set visibility for whole header, but you can set visibility for separate report items in header based on the export style.

Where that is set - it is set in report, in usual Hidden expressions. There is nothing to do with server config file to achieve this (the only point is to take a look at rsreportserver.config - it contains section with rendering extensions, it's useful to know their names, f.e. name "EXCEL" is for old binary XLS format, while "EXCELOPENXML" is for modern XLSX).

To set visibility based on the export style, you can use built-in report field RenderFormat.Name (notice that it is Name, not IsInteractive!). Just type the following expression for the Hidden property:

=Globals!RenderFormat.Name = "PDF"

In conclusion, you can't set visibility for whole header, you can show/hide report items inside header based on different conditions you want, but header will still take some place. To really hide the header so it will not consume the space of report, you can simulate the header with rectangle and page breaks, this is the workaround.