SSRS - Dynamically shrink header - reporting-services

I need to shrink dynamically height of header on ssrs
I have found answer on: How to dynamically increase the page Header height in SSRS 2008 , but still I have problems as follows.
I have SSRS with several text boxes, (10 lines), and I want to show only one line for page 2 and after, and for page 1 - all of the lines.
I cannot shrink the size, because minimum size of header by default is the maximum element bottom position.
Can I control the size of height of the header dynamically?
Thanks :)

Page header and footers can not be dynamically sized. This allows support for more output devices but limits its use for many situations. A common work around is to use a Parent group above all others in your dataset that has a sql command that returns 1 row such as SELECT OneRow=1. You could place your header logic in this print once groups header and optionally show or hide the header based on first page last page etc.

Related

Why last rows are printed in the middle of the page if there's a lot of empty space?

I'm developing this report:
The problem I'm facing when printing a document with multiple lines is that rows are not printing together when there is a lot of space for it:
Header properties:
Footer properties:
I don't know why it's not printing on top of the 2nd page header and it leaves a huge blank space... there is also enough space in the 1st page to print all rows
Report property ConsumeContainerWhitespace is set as True
How can I use all that empty space with the rows instead of printing blank?
The header and footer are fixed spaces. This means that even if you hide the content on one or more pages, the space will still be reserved on layout.
The result is that the space available for the lines is limited on each page and the render engine needs to split them to multiple pages.
You can solve the issue with the header by moving it to at header row in the tablix.
The footer is not possible to do any different if the placement at the bottom of the page is a requirement.

Tablix pushing other elements down

I have a report with a tablix in it. I just need to stay the tablix in a fixed position and shouldn't push down other elements down it. If say there are 4 rows which will be visible in the specified space and if more then it should not be visible and shouldn't push down other elements.
I tried several ways to prevent
Added tablix inside a rectangle(act as a container) so if it grouped it
will not push down other elements (didn't work)
Enable consume white space in report=true (didn't work)
Keep items together property is set to true in rectangle (didn't work)
Is there any other way to not to pushdown elements in the report even if the tablix gives more rows. It should only show the rows in the mentioned size.
Edit : 1 (7/28/2018)
All the three elements below is pushed down if the table has more rows.
Either I have to fit the rows in this table by reducing the size automatically if possible or It should not push down the elements.
Also if the tablix has less row the elements will move up. I just need to keep the elements (Expr) should stay in the same position.
You still didn't post your design but anyway, here is what I think you want.
The basic idea to to set the area you want you table to cover by using a rectangle of the same size. Then we will reduce the row heights within reason as the number of rows in the table increases. As you cannot directly change a row height, we can get round this by setting the row height to be very small and adjusting the font, as long as the can grow option is on the cells will grow to fit the font size, giving the effect of changing the row height.
Basic steps.
Create your report and add a rectangle that is the maximum size you want your table to be. In my example it's 38mm high.
Create a table inside the rectangle. I find this easier to create it outside then cut and paste it inside, simply dragging it over the rectangle will not work.
Position your additional text boxes, under the rectangle as desired. Set 'Consume Container WhiteSpace' on in the report properties.
Next we need to decide what the maximum and minimum font sizes are that acceptable. In this basic example I only use 3 sizes, 10pt, 12pt and 14pt. If you want to use more then you could write an expression to scale the fonts more accurately but you get the idea.
You'll need to determine the maximum number of rows you can fit into the rectangle when the minimum font size is used, in my case it's 5 rows at 10pt font. Your query will need to take this number into account and never return more rows than this.
On the table, the click row selector for the detail row (this basically selects all the cells in the row). Next, change the font size property to an expression. In this simple example I used this.
=SWITCH(
Parameters!topx.Value <3 , "14pt",
Parameters!topx.Value <5 , "12pt",
True, "10pt"
)
Next set the row height, choose any cell on the row and set the height to something small, I used 4mm but it doesn't matter as long as its' smaller then you will ever show.
In my example, for testing I added a 'topx' parameter and filtered the dataset using this, but this is only for testing.
The final design looked like this. I added a background colour to the rectangle so you can see how it remains static until it's filled.
Then running with various rows looks like this
finally, only if I exceed my maximum (5 rows in this case) does the text below move down.
You could include a column (let's call it RowNumber) in your dataset that shows the row number of the data. Then in your Tablix filter, you can set the filter to show only values from that "RowNumber" column that are less than or equal to the number of rows you want to display in the tablix.
You can use the same concept to limit the number of rows returned in your query, but without knowing how you are getting the data, it is not possible to help with that.
If you want your report to be that static, why not take a screenshot of the data and include that as an image in your report?
No serious reporting tool will "ignore" records that you pass to it using a Dataset, so that's the place where you will have to "ignore" all unwanted data yourself. Restrict the data in the Dataset to only 4 rows (maybe using SELECT TOP 4 ...).

Dynamic Page Header/Footer width in SSRS

How is it possible to control the width of the page header and page footer (dynamically) based on the detail record in ssrs.
I am using a matrix in my detail section. Here, more month names can be added based on data. The width of header should be of same length of matrix width from detail section.
Thanks
Does it have to be the page header? If you make it the table header it will size with the matrix and you can have table headers repeat across pages which should achieve the same effect.
Now this answer isnt the cleanest but you could create 2 different size headers that are on top of each other. Then in the Header properties; use an expression in the "Hidden" property like so:
First Header
=iif(Parameters!YourParameter.Value < 3,TRUE,FALSE)
Second Header
=iif(Parameters!YourParameter.Value >= 3,TRUE,FALSE)
Now the 1st Header will be hidden when the value is less than 3 and the 2nd header will be hidden when the value is greater than or equal to 3.

SSRS hidden column creates extra blank page

I have a report with a Tablix where I would like it almost full page width. "Gross Pay" is visible or not based on a parameter. I have also added a blank column to the left of this which has the opposite visibility to "Gross Pay" as a work around for the fact that I can't resize tablix width dynamically so the whole tablix stays the same width.
This is all fine and works but spits out an extra page when saving to pdf. This is because my body width is greater than 21cm. Below is the tablix, the red line is where page end is.
My body width must be 24cm in the designer to accommodate this hidden field but will always display under 21cm in the end. Can I have a body width in the designer larger than the page size? Alternate solutions would also be appreciated.
Thanks!
I ended up removing the blank column and just using expressions for all fields on the "Gross Pay" column that would fill it as blank if appropriate parameter was set.

Repeat a vertical line on every page in Report Builder / SSRS

I wish to include a vertical line on every page of my report, which runs from the top to bottom of the report body. How can I achieve this?
I've tried using RepeatWith, but it doesn't seem to work, the line appears only on the first page.
Thanks
Is this for look and feel purposes only?
I would create an image with such line and use it as the body background. Or if you're using a tablix that spans across multiple pages, another idea would be to create an empty column on the tablix with a border on the left side.
And yet another idea would be to use a rectangle with a left/right border and place all your tablixes inside the rectangle as this would make the rectangle to be expanded to multiple pages keeping the border (the vertical line) on your report.
I don't think that you can tell SSRS to automatically repeat lines on multiple pages.
I've figured out a way to solve that problem (without using RepeatWith, RepeatOnNewPage or Report Background Image)
I wrote a simple code to add blank rows to the table in the body. The number of rows to be added will be determined by the body height and the height of a row.
For example, if the body height is 6" and height of a row is 0.5" then a total of 12 rows can be fitted into one page. So if your table has 4 rows then add 8 extra black rows so as to make the table height equal to the report body.
If the number of rows is more than 12, say 15, then you'll add [12 - (15 mod 12)] rows
, i.e. 9 blank rows.
And you can have side borders on any of the columns as required, resulting in a vertical line running throughout the page.