HTML String Rendering in a Report

We have a "Comment" field that is saved as a HTML string to the DB. This field needs to be pulled into a report as rendered HTML.

I know this has been hashed out before, but has anybody found a good solution in the past couple of months

We are thinking about storing two versions of the Comment in the DB: one with HTML, one as simple text. Has anybody found this an acceptable solution I know it flies in the face of good DB design, but it seems the quickest, easiest solution...

Any word if this will be fixed in the next major release of SSRS Can we expect this release any time soon

Thanks for looking,

Smith



Answer this question

HTML String Rendering in a Report

  • zdjray

    Line breaks (\r\n) are translated into a linebreak in HTML (<BR>). If you're seeing boxes, your data probably just uses \n to represent a linebreak. Try doing a .Replace("\n", "\r\n") on the value of your textbox.

    Tabs will be passed through to HTML but web browsers will treat them as general whitespace and ignore the fact that they represent a larger indentation.

    Thanks, Donovan.



  • Kramish

    Yes, that is exactly what I'm trying to accomplish... And that's what I was afraid of. I think our coders have some custom controls to do just this...

    How does SSRS interpret plain text strings to keep formatting such as line breaks and tab formatting Does anybody have any text encoding recommendations that works well with SSRS I looked at some legacy data and it has little square boxes in it to represent line breaks. I don't want to lose all my formatting ...

    Smith




  • Ted Glaza

    I have used a user defined function to strip the HTML tags from the text in the SQL query:

    Create Function dbo.fnStripTags
    (@Dirty varchar(4000))
    Returns varchar(4000)
    As

    Begin
    Declare @Start int,
    @End int,
    @Length int

    While CharIndex('<', @Dirty) > 0 And CharIndex('>', @Dirty, CharIndex('<', @Dirty)) > 0
    Begin
    Select @Start = CharIndex('<', @Dirty),
    @End = CharIndex('>', @Dirty, CharIndex('<', @Dirty))
    Select @Length = (@End - @Start) + 1
    If @Length > 0
    Begin
    Select @Dirty = Stuff(@Dirty, @Start, @Length, '')
    End
    End

    return @Dirty
    End


  • ploc

    Thank You!

    This is the first time I’ve implemented a DB function. I’m a noob (as if you couldn’t tell).

    While it still doesn’t solve my underlying problem, retaining formatting, it does offer one more step toward a solution.

    Has anybody taken it a step further and inserted chars, like dots for bullets, into the resulting output based on the <li> tag That’s my next step; if it’s feasible.

    The customers\ bosses won’t be happy with the loss of formatting, but if they don’t get their bullets… it’ll be grim.

    Smith


  • Nic Butler

    Hi Luis,

    Do you mean you can display HTML in SQL Report Services using Webservices

    Do you have a url for your blog, or the article you mentioned

    Philip


  • Zartor

    Try translating tabs into spaces, ie:

    Fields!Field.Value.Replace("\t", new String (' ', 10))

    We should translate multiple sequential spaces into non-breaking spaces - &nbsp; so this should work though I'm not sure how consistent it will appear across the various renderers.

    Thanks, Donovan.



  • Jose M. Ladero

    I assume that you want to do the following: You have a HTML string (stored in a database or , so if you have a wherever) and you want to display the HTML as it is, so if you have a <b> tag you want to keep the font bold. Now the bad news, HTML display is not supported yet. You could do a workaround, parsing the data in your custom code and give the plain text back, because RTF boxes can’t be condigured to switch between font settings.

    HTH, Jens Suessmeyer.

    ---
    http://www.sqlserver2005.de
    ---

  • tonic999

    Have your tried rendering with webservices

    Take a loot at my space/blog, there is agood article about it, maybe its what you need



  • Ikuko O.

    Sorry. No, RTF is not supported. Line breaks and space-based indentations are special cases.

    Thanks, Donovan.



  • Jon_The_Coder

    Thanks for your input...

    I guess the natural progression of questioning this is how would I force the Report Designer (in BIS) to keep an indention made during design

    I can get it to render fine in preview; not so fine in deployment or exporting. I've tried using HTML tags to render the indention for deployment, but they get rendered as text as well in preview and deployment.

    Anybody know the status of a SSRS updates

    Thanks,

    Smith





  • Charles Aimer

    Are you saying RTF display is supported Is there a control for that


  • jplh

    Sure, you can replace the li tag with CHAR Code 149 by doing something like this here:

    REPLACE(SomeColumn,'<li>',CHAR(149))

    and of corse remove the other tag like REPLACE(SomeColumn,'</li>','')

    HTH, Jens Suessmeyer.

    ---
    http://www.sqlserver2005.de
    ---


  • HTML String Rendering in a Report