Another solution I came up with is using VB.NET, in particular the TextRenderer.MeasureText () function.
To make this work, I added the following code to the report:
Public Function TextWidth(str As String) AS Double
'Returns the width, in pixels, of a string, assuming Tahoma size 8.
Dim size As System.Drawing.SizeF
Dim font As New system.Drawing.Font("Tahoma", 8)
size = System.Windows.Forms.TextRenderer.MeasureText(str, font)
TextWidth = size.Width
End Function
Public Function TextCap(str As String, maxWidth As Integer, Optional suffix As String = "") As String
'Truncates a string to fit within maxWidth pixels, optionally adding a suffix string if
'any characters were truncated.
Dim w As Integer, l As Integer
l = Len(str)
w = TextWidth(str)
For i As Integer = 1 To 10
If (w > maxWidth) Then
l = (l * maxWidth / w)
If (l < 0) Then
l = 0
Exit For
End If
w = TextWidth(Left(str, l) + suffix)
Else
Exit For
End If
Next i
If l < Len(str) Then
TextCap = Left(str, l) + suffix
Else
TextCap = Left(str, l)
End If
End Function
System.Drawing(2.0.0.0) System.Windows.Forms(2.0.0.0). TextWidth , Tahoma, 8. , .
TextCap SSRS, :
=Code.TextCap(Fields!CustomerName.Value, 150, "...")
150 , "..." .