Html 如何在 report.rdlc 中呈现格式化文本(及其格式)
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/16634874/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to render the formated text in the report.rdlc (with its format)
提问by Anyname Donotcare
I store my data in formatted way in my db ,
I want some way to render the text with its format in my report.rdlc
i use visual studio 2008 How to do this :
我将我的数据以格式化的方式存储在我的数据库中,我想以某种方式在我report.rdlc
使用 Visual Studio 2008 中使用其格式呈现文本如何执行此操作:
For example :
例如 :
if my text like this :
如果我的文字是这样的:
<p>text</p>
It appears the same with tags in my report text box !!. instead of rendering as a paragraph.
它与我的报告文本框中的标签显示相同!!。而不是呈现为段落。
when i bind like this :
当我这样绑定时:
= Fields.subject
How to fix this problem ?
如何解决这个问题?
回答by Chris Latta
Edit
编辑
After researching this problem a bit more it appears Visual Studio doesn't support Markup as HTML for rdlc
reports until Visual Studio 2010. So if upgrading is an option, then you can do what you want.
在对这个问题进行了更多研究之后,在rdlc
Visual Studio 2010 之前,Visual Studio 似乎不支持将报告标记为 HTML 。因此,如果升级是一种选择,那么您可以做您想做的事情。
Otherwise you could always just strip out the HTML tags like so:
否则你总是可以像这样去掉 HTML 标签:
On the Report
menu, click Report Properties...
and select the Code
tab. Enter the following code:
在Report
菜单上,单击Report Properties...
并选择Code
选项卡。输入以下代码:
Function StripHTMLTags(ByVal text as String) AS String
Return System.Text.RegularExpressions.Regex.Replace(text, "<(.|\n)*?>", "")
End Function
Now in your cell use the following expression:
现在在您的单元格中使用以下表达式:
=Code.StripHTMLTags(Fields!MyField.Value)
Original answer follows:
原答案如下:
Leaving aside that you should separate data from presentation, you can render using HTML tags in Reporting Services, its just not very intuitive to find:
撇开您应该将数据与表示分开,您可以在 Reporting Services 中使用 HTML 标记进行渲染,它只是不太直观地找到:
- Left click the field you want to display so that the
<Expr>
tag is highlighted - Right click the highlighted
<Expr>
tag and choosePlaceholder Properties...
- On the
General
tab, select theHTML- Interpret HTML tags as style
radio button
- 左键单击要显示的字段,以便
<Expr>
突出显示标记 - 右键单击突出显示的
<Expr>
标签并选择Placeholder Properties...
- 在
General
选项卡上,选择HTML- Interpret HTML tags as style
单选按钮
Only a limited number of tags are supported however. This article on MSDNtells your more.
但是,仅支持有限数量的标签。MSDN 上的这篇文章告诉你更多。
Screenshots:
截图: