1

I'm new to SSRS and I'm unable to align the sentence horizontally in a straight line in SSRS using HTML tag.

I've got a very long word and I want it to fit in a line. I tried using can grow in SSRS but it expands the text box in a vertical manner with the word moving to the next line. However, I want the words to fit in a horizontal line and the extra to be visible as long as the text box holds.

Is there any HTML tag/code in SSRS which would help me achieve the same?

Chris Latta
  • 20,316
  • 4
  • 62
  • 70
Prithvi P
  • 13
  • 2
  • What tags are you trying to use and what result are you trying to get? There may be another way to achieve the outcome you want. – Chris Latta Oct 16 '21 at 08:26
  • Hi Chris, I've a very long word and I want it to fit in a line. I tried using can grow in SSRS but it fits the word in a vertical manner in the next line but I want the words to fit in a horizontal line and the extra to be visible as long as the text box holds. Is there any HTML tag/code in SSRS which would help me achieve the same? – Prithvi P Oct 17 '21 at 10:57
  • Okay, try the method I've added to my answer – Chris Latta Oct 18 '21 at 00:42

1 Answers1

0

SSRS only supports a very limited set of HTML tags, so HTML is often not that helpful to format your text.

From this MSDN article, the list of supported tags are:

  • Hyperlinks: <A HREF>
  • Fonts: <FONT>
  • Header, style and block elements: <H{n}>, <DIV>, <SPAN>, <P>, <HN>
  • Text format: <B>, <I>, <U>, <S>
  • List handling: <OL>, <UL>, <LI>

So we can achieve the result you are after (that is, show as much of the text as possible in the horizontal confines of the text box) by combining the <DIV> HTML element with non-breaking spaces.

To do this, follow these steps:

  1. Set the cell's CanGrow property to False so it won't expand vertically

  2. Set the cell's Markup Type to be HTML - Interpret HTML tags as styles

  3. Enclose the field's text in <DIV> tags and replace the spaces in the text with non-breaking spaces by setting the cell's expression to:

    ="<DIV>" & Replace(Fields!FieldName.Value, " ", "&nbsp") & "</DIV>"

Chris Latta
  • 20,316
  • 4
  • 62
  • 70