SSRS 2008 multi-line data displaying as one line in report

▼魔方 西西 提交于 2019-12-06 02:39:33

There are two directions to accomplish this. The method you want depends on whether or not you are formatting the text as HTML (Right click on the text in the cell, select Placeholder Properties. If Markup type is HTML, use the first approach below.)

Sounds like you are presenting these as HTML, since the vbcrlf will be displayed if you set to None.

Treating the text as HTML:

You need to replace the vbcrlf with <br/> tags. This is easiest if you use embedded code in the report. Create a function in the report's code: Report menu, Report Properties -> Code section.

Public Function ReplaceLineBreaks(ByVal s As String) As String
   Dim strBuilder As New System.Text.StringBuilder(s)
   If s.Contains(vbCrLf) Then
      strBuilder.Replace(vbCrLf, "<br/>")
      Return strBuilder.ToString()
      Else : Return s
   End If
End Function

Now set your field to use this code: =Code.ReplaceLineBreaks(Fields!ColumnA.Value)

If you aren't treating the text as HTML

vbCrLf should be preserved and displayed in this case, so if that's really what you have stored in SQL, then you should be fine. If you have some other characters instead in the string, you can alter the ReplaceLineBreaks function I provided above to insert vbCrLf's.

If you have vbCRLF's in your table then this is not the correct way to approach the problem. SSRS will render vbcrlf as a string and not as a carriage return line feed this way.

You should return 3 separate columns to your data set:

Name, Role, Office

Dan Cheif, CEO, Indian Office

In your tablix you could then do an expression where you want this line to be displayed:

=DataSet!Name.Value & vbCRLF & DataSet!Role.Value & vbCRLF & DataSet!Office.Value

I havent worked too much on SSRS. But one thing what i would suggest is to create a placeholder in that text field. You can then use html style tags to break the data into multiple lines. But of course, i believe you can only use this method when u have multiple expressions to be filled in the same field. Havent tried a situation wherein the database itself contains multi-line information. Hopefully the below link will explain the procedure better.

http://sqlserverpedia.com/blog/sql-server-bloggers/using-different-formats-within-a-single-textbox-in-ssrs/

You can see which all html tags are supported in ssrs here

http://social.msdn.microsoft.com/Forums/en/sqlreportingservices/thread/3bffb40a-c67f-4cb2-a3dd-ce711200e8db

In my case, the Full_Address field I was outputting to a textbox contained a CR (CHAR(10), in SQL terms) but not an LF (CHAR(13)). (Discovered this by using the CHARINDEX function.) So what I thought of as the individual lines of the full address were not line-breaking on the SSR output. It kind of line-broke when it ran out of room in the SSRS report's textbox field, horizontally speaking.

So what I did in my stored proc was this: SELECT ...REPLACE(Full_Address, CHAR(13), CHAR(10) + CHAR(13)) AS FullAddress, ...

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!