Stripping HTML tags from SSRS text fields

I have worked extensively with SSRS. One of the common requirements is to strip HTML from text values displayed in reports and apply standard formatting to the text.
HTML have many encoded characters which end users don’t want to see.

The function below replaces encoded characters to the correct string
http://www.w3schools.com/tags/ref_urlencode.asp

The requirement was to add a carriage return whenever a “<br>” is found. Because in some text the “<br>” was “<BR>” and “<br/>”, additional code has been added to cater for them.

The <li>tag needed to be preserve somehow explaining why it’s been converted to “-”
Finally the function uses the Regex expression “<(.|\n)+?>” to strip any html

To use the above function, follow the steps below
1. Navigate to report properties>code tab. Copy and paste the above code.

2.Call the function from any textbox value property where needed as follows:
=Code.StripHTML()

Advertisements