Wednesday, May 27, 2009

SSRS Column Width Long Text Problem

Recently I got a weird problem building some reports with SSRS 2008. The column width started to automatically resize based on content, while all columns width are fixed in SSRS by design. The cause of this was long words and long URLs in these fields, which were not able to wrap. Looks like HTML table was adjusting the column size accordingly. (By the way, it was still showing Ok in preview, but was changing the size of columns in published version.) Spent quite a time trying to figure out what to do with that, cause I need those column widths to be static. Here is the solution:

While this problem is caused by native HTML functionality, we can use HTML to fix it.

  1. Change Expression to be something like =”<DIV style=’width:1.2in’>” & Fields!YourField.Value & “</DIV>” where width is the desired static width of this column.
  2. Change placeholder properties – General tab – Markup type – HTML-Interpret HTML tags as styles. (Placeholder properties can be accessed by right clicking on Expression (Field) inside of the cell, not on cell itself).

PS. I am also sure that you can use the same approach to create columns with adjustable or auto width, it just needs some tweaking. Update: Here it is.

11 comments:

  1. Hello I'm logesh.. I tried this.. but then the style attribute is throwing some error.. Help me on this

    ReplyDelete
  2. thank you very much.
    your post really save my day!!

    in order to solve my problem, i need to change from 'div' tag to 'table' tag. 'div' doesn't work for me.

    however, this content give me an idea to figure it out. thanks a million !!!!

    ReplyDelete
  3. This is awesome. You're a lifesaver, I wasted almost a day on tweaking a couple of troublesome columns in my report

    ReplyDelete
  4. Amazing. Thanks a lot

    ReplyDelete
  5. Can you explain step by step of dynamically changing width in SSRS

    ReplyDelete
  6. Can you give me solution for dynamically changing column width in SSRS

    ReplyDelete
    Replies
    1. Check my other blog post at http://blog.sharepointalist.com/2009/05/ssrs-column-width-auto-size.html

      Delete
  7. Thank you very much for this post; I spent hours and hours trying to determine the problem and solution for this behavior. This soultion worked perfectly!!

    ReplyDelete
  8. Thank you ! This saved me a a lot of grief!
    The only thing I would say is maybe add an intermediate step where you specify that the user needs to select the text to get to the placeholder properties. Again, thank you!

    ReplyDelete
  9. It's still saving time.
    Thank you so much.

    ReplyDelete