Question

Text Field Line Breaks in SSRS

  • 14 September 2021
  • 4 replies
  • 789 views

I’m trying to create a report that references a field that can be multiline.  I am using a Tablix and the issue comes that the cell formats the carriage returns out of the field.

IE: Comments Show:

Line1
Line2
Line 3

SSRS Tablix Shows:

Line1Line2Line3

 

Is there a way to keep the formatting?  I know it’s there because I can export a BAQ into Excel with the comment and it shows properly.


4 replies

Userlevel 3

Epicor doesn’t store the complete both the carriage return and line feed.  So you have to go through and replace where it’s just one character with both.  I do a function like the below in my SSRS reports and then I can call it when needed.  This does the replacements for line breaks as well as if there are multiple spaces.

 

Public Function StripReturns (source as string) as string	source = source.Replace (vbcrlf, "~").Replace (chr(10), "~").Replace (chr(13), "~")	while source.Contains ("~~")		source = source.Replace ("~~", "~")	end while	while source.Contains ("    ")		source = source.Replace ("    ", "  ")	end while	source = source.Replace ("~", vbcrlf)	return sourceend Function

I’m pretty new to the SSRS world.  Can you elaborate a bit on how to implement this?

I assume the code goes in the Custom code section of the report properties.

How do I go about calling the function in a tablix field?  The field I’m trying to show would be CRMCall.CallText

Userlevel 3

Hey, I teach a couple courses in SSRS and can get you the info that way!  lol 

Yes, in the Custom Code for report properties you’ll put that function.  Then in your tablix cell, right-click | Expression.  Enter something similar to the following: 

=Code.StripReturns (Fields!CallText.Value)

You can type the Code.StripReturns() and then put the cursor in between the parens, then go down and click on fields and double-click your specific field and it should fill in the Fields!XXX.value.  

 

Let me know if that doesn’t get you going.

That did the trick.  I was almost there before messaging back.  I left Code out of the expression.  Thank you for the assistance.

Send me the info on the courses you teach.  I’m looking for opportunities to further my knowledge.  I have been using Crystal for so many years.  This is a bit of a steep learning curve.

Reply