1

我有一个水晶报表,其中显示了从 a 检索到的编码文本DataSet,但在报表中,它显示的是 html 标记。

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

4

1 回答 1

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
于 2013-01-08T09:34:19.383 回答