I'm working on a tablix in SSRS 2008 and want my columns to autosize (width only) to their contents. CanGrow only affects height. Is there a property I'm missing or any way to otherwise rig the columns to do this?
-
This solution relies on adding a dynamic width chart to create a Dynamic Column Width in Tablix– KyleMit ♦Mar 24, 2017 at 13:18
7 Answers
I've been trying to do that myself (client side), without success. There is no property that would autosize the column width.
Check out this workaround: http://blog.sharepointalist.com/2009/05/ssrs-column-width-auto-size.html (I haven't tested it)
The best workaround I've found for client side reporting would be to set column's width in code or use multiple columns and show/hide them based on string length condition.
For example, column named AccNum2:
report.DetailSection1.ReportObjects.Item("AccNum2").width = 200
See this thread for details and other ideas: http://social.msdn.microsoft.com/forums/en-US/sqlreportingservices/thread/9e6043f1-c458-4540-be59-d37b02feab8a/
As mentioned here, an easy fix to this issue is to add a row in your tablix and insert a chart to the corresponding column.
Then change its DynamicWidth
to an expression like the following =iif(True, "4cm", "2cm")
and its DynamicHeight
to "0cm".
-
This is working great on width. I'm having a lot of problems hiding the artifact and keeping the size of the row 0– Craig.COct 1, 2021 at 16:17
-
So this works fine in the pdf version and online so long as I go into the code and set height to 0 in there. It comes out at like a minimum height in the visual studio preview which is a bit off putting but can be ignored.– Craig.COct 1, 2021 at 17:53
we can change width dynamically .follow the below steps
step1:add one more column
step2:merge the added columns with original one
step3:add column visibility expression for extra column based on your requirement
still your not getting then see attached picture
-
Could you please elaborate more your answer adding a little more description about the solution you provide? Jun 16, 2015 at 10:11
-
The solution from SHOWKATH VALLI worked best for me. An absolute genius idea!
This is how I implemented it:
- Create an additional column to the right of the one you need widening
- Merge the cells
Click on the column visibility of your new column.
Hide/show based upon a calculation or in my case a value in my select statement that this is a wide column.
Here is the expression I created: =IIF(Fields!Static1Wide.Value=0,True,False)
-
-
1Here's another post that proposes the same solution, with pictures: stackoverflow.com/a/16262756/980945 Sep 5, 2017 at 21:29
-
1What if this takes you over the width of your page? Seems to be causing me an extra page of whitespace per table.– Craig.COct 1, 2021 at 15:28
-
=IIF(Fields!Static1Wide.Value=0,True,False) is the same as Fields!Static1Wide.Value=0– Craig.COct 1, 2021 at 17:55
I got around this with a table that had email addresses in it by using an expression for the 'EMAIL' field:
=Replace(Fields!EMAIL.Value, "@", System.Environment.NewLine & "@")
You could do something similar if you needed it after say 15 chars (insert the System.Environment.NewLine code after every 15 chars) maybe.
This may not be the answer you're looking for, but having to adjust width for over 100s of columns at once is just not fun and this little hack does save time.
- Create your report through Report Wizard and add All columns you'll need in your report. Doing this created your Tablix! Saves plenty of time since you can select all columns at once.
- Next, right click the .rdl file under Solution Explorer > Reports section
- Select "<> View Code"
- Look for 1in xml tag. 1 inch width is by default. You can replace 1in with 2in for all columns!
- Finally, run your report and see if you need to make any adjustment for any columns that did not fit your 2 inches concept.
Give this method a try. If you find anything better or improvements..do let me know!
-
1The question concerns getting the columns to grow based on the data contents. You are describing how to mass-redefine widths, but not providing a way for the data to cause the column to get wider.– binkiDec 23, 2019 at 14:36
To change column width
In Design view, click anywhere in the Tablix data region to select it. Gray column handles appear on the outside border of the Tablix data region.
Hover over the column handle edge that you want to expand. A double-headed arrow appears. Click to grab the edge of the column and move it left or right to adjust the column width.
Check the image below: (im unable to post images here due to low points) http://i.stack.imgur.com/FvCQF.jpg
Reference: http://technet.microsoft.com/en-us/library/cc645971(v=sql.100).aspx
-
4The question is how to do this at run time with varying width content Jul 31, 2014 at 7:08