Crystal Report中的HttpUtility.HtmlDecode

时间:2013-01-04 13:28:35

标签: c# crystal-reports

我有一个Crystal Report,我在其中显示从DataSet检索到的编码文本,但在报告中,它显示的是html标记。

有没有办法解码文本并将其显示在水晶报告中?

1 个答案:

答案 0 :(得分:1)

这是我的SQL函数,用于解码编码文本..

CREATE FUNCTION FNHTMLDECODE (@REMARKS NVARCHAR(MAX))
RETURNS NVARCHAR(MAX) AS  
BEGIN 
    DECLARE @RESULT     NVARCHAR(MAX)
    DECLARE @VCCRLF     VARCHAR(2)

    SET @VCCRLF     =   CHAR(13) + CHAR(10)

    SELECT @RESULT  =   @REMARKS

    SELECT @RESULT  =   REPLACE(@RESULT,'&','&')
    SELECT @RESULT  =   REPLACE(@RESULT,'&','&')
    SELECT @RESULT  =   REPLACE(@RESULT,'&#','&#')
    SELECT @RESULT  =   REPLACE(@RESULT,' ',' ')
    SELECT @RESULT  =   REPLACE(@RESULT,'&lt;','<')
    SELECT @RESULT  =   REPLACE(@RESULT,'&gt;','>')
    SELECT @RESULT  =   REPLACE(@RESULT,'&QUOT;','"')
    SELECT @RESULT  =   REPLACE(@RESULT,'&COPY;','©')
    SELECT @RESULT  =   REPLACE(@RESULT,'&LAQUO;','«')
    SELECT @RESULT  =   REPLACE(@RESULT,'&RAQUO;','»')
    SELECT @RESULT  =   REPLACE(@RESULT,'&FRAC14;','¼')
    SELECT @RESULT  =   REPLACE(@RESULT,'&FRAC12;','½')
    SELECT @RESULT  =   REPLACE(@RESULT,'&IQUEST;','¿')
    SELECT @RESULT  =   REPLACE(@RESULT,'<BR />', CHAR(10)) --   LINE FEED
    SELECT @RESULT  =   REPLACE(@RESULT,'&#x0D;', CHAR(13))  -- CARRIAGE RETURN

    SELECT @RESULT  =   REPLACE(@RESULT,'<P>',@VCCRLF)

    RETURN @RESULT
END