SSRS Report Builder not showing Rich Text from DB

2019-09-15 04:27发布

问题:

I'm using SSRS (specifically the Report Builder) for generating some fairly basic reports from SQL Server 2012. Report Builder 3.0. When I add a field from the database that is stored as rich text (with the tags and all), it simply displays all of those tags right on the report, instead of showing the properly formatted text.

I've dug around in the tools as much as I can, and can't find a way to get that field to display in a formatted way.

Is there a function, or setting, somewhere that I'm missing that will get the text to display properly?

回答1:

I don't believe it's possible to display Rich Text in an SSRS report.
You could render the Rich Text to an image file, and then display the image on the report.

However, it is possible to use HTML markup which could also be of use to you.

To add HTML from a field in your dataset into a text box

  1. On the Insert tab, click List. Click the design surface, and then drag to create a box that is the size you want.

    The Dataset Properties dialog box opens. You can use a shared dataset or a dataset embedded in your report. For more information, click Dataset Properties Dialog Box, Query (Report Builder) or Dataset Properties Dialog Box, Query.

  2. On the Insert tab, click Text Box. Click in the list, and then drag to create a box that is the size you want.

  3. Drag an HTML field from your dataset into the text box. A placeholder is created for your field.

  4. Right-click the placeholder, and then click Placeholder Properties. On the General tab, verify that the Value box contains an expression that evaluates to the field you dropped in step 3.

  5. Click HTML - Interpret HTML tags as styles. This causes the field to be evaluated as HTML.

  6. Click OK.


Source: MSDN - Add HTML into a Report (Report Builder and SSRS)

This means you have a couple of options:

  • You could write a function that removes the Rich Text tags, leaving you the plain text to display.
  • Render the Rich Text to an image file and display the image on the report.
  • Instead of using Rich Text in your dataset, you start using HTML markup.
  • Write a function that replaces the Richt Text tags with equivalent HTML styled tags. This would be a little more work but still a valid solution.