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

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:


4 thoughts on “Stripping HTML tags from SSRS text fields

  1. Hi, I tried to use your function and I get an error ” String constants must end with a double quote”.
    thanks. Using Visual Studio 2013 for report design.


  2. Thanks for trying the code. Unfortunately the original code which has encoded characters got converted into plain text.
    I have updated the post with a link to gist.
    Can you please try the code again?


  3. Appreciate the code. One question;
    Why is this required?
    Dim objRegExp AS NEW System.Text.RegularExpressions.Regex( “”)
    and RETURN objRegExp.Replace(sInput, “”)
    Wouldn’t a simple return of sInput suffice? What am I missing here? Been racking my brain for hours. Thanks!


    • Hi TimK

      The HTML text I had to work with had encoded characters , for example “&” instead of “&”.
      The regex expression will remove all HTML tags but for my requirements, I wanted to preserve line breaks () , so I am handling these tags individually to be replaced with line feed (chr(10)). Also had to transform to bulleted string , in the example above I am replacing “” with “-“.
      Depending on your requirements, thus you might have to amend the code further.



Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s