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.

6 comments:

  1. This is fine but I want to run both functionality that when click on column open a sub report and when i see that report in excel hyperlink will not show.

    ReplyDelete
  2. i have same issue, i just wanted hyperlink working when i export my main report into excel.if anyone can help on this issue.

    ReplyDelete
  3. Not working for SSRS 2016. Anyone have another source that works for ssrs 2016?

    ReplyDelete
    Replies
    1. Don't use 'Excel', instead use 'EXCELOPENXML'.

      Delete

About Me

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