none
Replace sharepoint code or replace invalid characters with empty strings in report builder 3.0 RRS feed

  • Question

  • I like to replace or remover the following strings in my report <dir> </dir> and <font face="Calibri" size="2" color="black"> I'm using the followiing code also listed below: (but I'm unable to put multiple strings like <dir> </dir>. Please help

    Public Function CleanSPSInput(strIn As String) As String

    Dim RegEx as System.Text.RegularExpressions.Regex

    ‘ Replace invalid characters with empty strings

    if strIn = "" OR IsDBNull(strIn)

    Return ""

    Else

    Return Regex.Replace(strIn, "<div>", "")

    End If

    End Function

    Date Entered

    Content Type

    Entered by

    05/08/13

    This is a test for Bharat</div>

    Bharat Patel

    04/16/13

    test</div>

    James Weaver

    02/11/13


    <font face="Calibri" size="2" color="black">- No updates - CB development is in process.</font></div>



    Brian Hadley

    Thursday, May 9, 2013 4:14 PM

Answers

  • Once you added the above code and applied to the cell as mentioned, click off the cell, then click the expr in it (so the four letters are highlighted) and the properties pane, should have a option called markup type, which will be set to None - change this to HTML (there are only two choices)
    • Marked as answer by Bharat64 Thursday, May 9, 2013 7:17 PM
    Thursday, May 9, 2013 7:03 PM

All replies

  • For the field expression in your report, assuming you have something like this in the cell expression;

    Fields!ContentType.Value

    You will actually want;

    =code.CleanSPSInput(Fields!ContentType.Value)

    Thursday, May 9, 2013 4:21 PM
  • I do Sir
    Thursday, May 9, 2013 4:24 PM
  • Try this code on your report;

    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

    Then against the field expression;

    =code.RemoveHTML(Fields!Your_HTML_Content_Field.value)

    If this appears to help, you may also want to highlight the expression in the cell, then change the markup type to HTML.

    Thursday, May 9, 2013 5:19 PM
  • How do you mark expression HTLM
    Thursday, May 9, 2013 6:43 PM
  • Once you added the above code and applied to the cell as mentioned, click off the cell, then click the expr in it (so the four letters are highlighted) and the properties pane, should have a option called markup type, which will be set to None - change this to HTML (there are only two choices)
    • Marked as answer by Bharat64 Thursday, May 9, 2013 7:17 PM
    Thursday, May 9, 2013 7:03 PM
  • You Rock!!! I have some other question that you maybe able to answer If I could get your Masterful self to help...

    Thanks

    Thursday, May 9, 2013 7:19 PM