Removing Unwanted HTML Contents from SQL Server Reporting Services (SRS) Reports

Posted By Posted by: EPM Partners on June 20, 2011

When using SRS to deliver reports derived from data entered through multiline text fields, SRS frequently returns non alphabetic characters like those returned below:

The following VB function removes unwanted HTML content from data retrieved from the Project Server Reporting database that is managed originally within a multiple-Line field on a Project Detail Page (PDP).\

  • Start Microsoft Visual Studio (BIDS) and open your Report Project.
  • Right-click on the report canvas and select “Report Properties”.
  • Select the “Code” tab.
  • Paste into the Code textbox the following code:

 

Public FUNCTION RemoveHtml(ByVal Text As String) AS String
IF Text IsNot Nothing Then     

Dim objRegExp AS NEW System.Text.RegularExpressions.Regex(“<(.|\n)+?>”)       

Text = Replace(Text,”&#160;”, vbcrlf)       

Text = Replace(Text,”&#39;”, “‘”)     

Text = Replace(Text,”&amp;”, “&”)       

Text = Replace(Text,”&quot;”, “”””)       

Text = Replace(Text,”&lt;”, “<“)     

Text = Replace(Text,”&gt;”, “>”)     

Text = Replace(Text,”&copy;”, “”)       

RETURN objRegExp.Replace(Text, “”)

END IF
END Function

  • Click OK when done
  • Now back within your report, right-click your form field that you need to remove HTML from and select “Expression”.
  • Add the desired field from your dataset and then wrap it within the following function call.=code.RemoveHTML(Fields!Your_HTML_Content_Field.value)


Blog Posted In Blog Posted In: Reporting
Blog Posted In Comments Off on Removing Unwanted HTML Contents from SQL Server Reporting Services (SRS) Reports