Saturday, October 20, 2012

Disable hyperlinks/javascript when exporting SSRS report

"Disable hyperlinks/javascript when exporting SSRS report", this is a very common question and I was expecting a straight forward answer from google like enabling/disabling a property at report or server level. But I was unable to find any such thing and hence I took below turnaround to solve my problem.

Problem:
In my case I had a column where some names were coming and they were linked to some external URL, this was fine and as required when rendered through report-viewer control on my web-application's page but when I export this to report PDF/Excel I didn't want them as then these links become non-functional and show error message like invalid URL.

Solution:
I duplicated my column containing link, and removed action from newly created column. Now I set their visibility with below expressions.

Visibilty of column with action link associated:
=IIF(Globals!RenderFormat.Name = "PDF" Or Globals!RenderFormat.Name = "EXCEL", true, false) 

Visibilty of column without action link associated:
=IIF(Globals!RenderFormat.Name = "PDF" Or Globals!RenderFormat.Name = "EXCEL", false, true)

Please consider: This might not work for older versions of SSRS

Hope this will save a few minutes of someone. If you have some better approach for this issue, please add it in comments and I'll update that in this post with due credits. Thanks.

About Me

My photo
Delhi, India
Fun, music, travel and nature loving, always smiling, computer addict!!