Search code examples
reporting-services

Is there a way in SSRS to only display specific parts of a report when rendered in MHTML, vs when it is rendered in the Report Viewer?


I have created a fairly long SSRS report which is to be sent out daily via email and embedded in the email in MHTML format. The whole report is not necessarily needed for the email however and we'd like to keep it concise when viewed in this form. I'm wondering if there is a way to only show part of the report when it is rendered in MHTML and then the reports users can view it in the report viewer if they need the additional pages / content.

Looking at previous posts it looks like there are two inbuilt fields Globals!RenderFormat.Name and Globals!RenderFormat.IsInteractive that could be used in line with visibility expressions, but I haven't been able to find a workaround with either of them. Globals!RenderFormat.Name is generated after expressions are evaluated so this won't work. For example I would use:

=IIF(Globals!RenderFormat.Name = "MHTML", True, False) 

as a visibility expression to hide certain objects in the report when it is rendered in MHTML format, however Globals!RenderFormat.Name gets calculated later in the rendering process than visibility expressions do. As a result the applied visibility expression never finds the render format to be MHTML so keeps it visible to the user.

Globals!RenderFormat.IsInteractive on the other hand is generated prior to expressions are evaluated, but both of the formats that I want to use (RPL and MHTML) are considered to be interactive so I also can't use an IFF or SWITCH statement here to differentiate between the two.

Does anyone have any other potential solutions?


Solution

  • The easiest way to do this might be to add a hidden parameter (e.g. ExportMode) and set the default value to 0, meaning 'not in export mode'.

    Set Hidden property of the elements you need hiding to =Parameters!ExportMode.Value = 1

    Finally, in the subscription setting, set the ExportMode parameter to 1.

    Now when users open the report as normal, the parameter will be 0 and everything will be shown but when the subscription runs, the parameter will be 1 and the selected elements will be hidden.