views:

1116

answers:

3

I am using the asp.net web application and microsoft visual studio reportviewer control and rdlc for creating a report ( not using sql server reporting). I used the Product table to view the result. It has five fields and I display all the itemsin the report. One field is Description and it store the html code as the value(eg:

<div><ul><li>a</li><li>b</li></ul><b>aaaa</b></div>

). I want to disply the output of this html code in my report's description field. But in my report, it shows the html value that I stored in my table (:

<div><ul><li>a</li><li>b</li></ul><b>aaaa</b></div>

). How can I render the html in my report. Please give me a solution.

+2  A: 

See Rendering HTML in Reporting Services Text Boxes in SQL Server 2008

I've not tried it and may not apply to rdlc etc, so YMMV

gbn
+3  A: 

Dear Masoud as GBN mentioned in his link, by default SSRS doesn't provide any solution to Render HTMl from HTML Code block. but you can use one these solution to render HTML in SSRS reports.

  1. Use from SQLCLR to create a Rendered HTML PNG and sendit toyour reports
  2. use HTMLDecoder to decode html code block to Rendered HTML. this script can find at :
  3. You can Use below code block to convert simple html code to Rendered HTML

    Public Shared Function ConvertRtfToText(ByVal input As String) As String
         Dim returnValue As String = String.Empty
            Using converter As New System.Windows.Forms.RichTextBox()
                  converter.Rtf = input
                  returnValue = converter.Text
            End Using
         Return returnValue
    End Function
    

You can also use this code block

 Function RtfToText(ByVal value As String) As String
   If value.Contains("rtf1") Then
       Return System.Text.RegularExpressions.Regex.Replace(System.Text.RegularExpressions.Regex.Replace(System.Text.RegularExpressions.Regex.Replace(System.Text.RegularExpressions.Regex.Replace(value,"[\n\r\f]", ""), "({\\)(.+?)(})|(\\)(.+?)(\b)", ""), "{", ""), "}", "").Trim()
   End If
   Return value
   End Function

you can finally call these code onyour textbox with

  =Code.RtfToText(Fields!HTMLCode.Value)
  1. You can also use some utility like http://pebblereports.com/reportingservicesutilities/ to display Rendered HTML in SSRS
Nasser Hadjloo
A: 

hi all,

iam facing the same problem and i tried using the function

Function RtfToText(ByVal value As String) As String If value.Contains("rtf1") Then Return System.Text.RegularExpressions.Regex.Replace(System.Text.RegularExpressions.Regex.Replace(System.Text.RegularExpressions.Regex.Replace(System.Text.RegularExpressions.Regex.Replace(value,"[\n\r\f]", ""), "({\)(.+?)(})|(\)(.+?)(\b)", ""), "{", ""), "}", "").Trim() End If Return value End Function

on the report code and in the text expression used this

=Code.RtfToText(Fields!HTMLCode.Value)

but there is no effect the data still appear like this < b >electricity company< /b >

i don't understand these two sreps

**1-Use from SQLCLR to create a Rendered HTML PNG and sendit toyour reports

2-use HTMLDecoder to decode html code block to Rendered HTML. this script can find at :**

please help me as it is urgent problem

nermeen
The simple answer is don't put HTML in your database. It's just plain wrong.
ck
@ck: So, how do you store formatted text in a database? Invent a new text markup format?
Heinzi
Can start with SQL Server CLR here: http://msdn.microsoft.com/en-us/library/ms254498(VS.80).aspx
D.S.