SSRS-Handling different headers based on page number - reporting-services

Here is the similar imageI'm trying to create an SSRS report using SSRS 2008 R2.
I have a requirement to show different headers in different pages based on page number. For example, I need two textboxes to be shown in all the pages except page-1. So I put them in a rectangle inside report header and set the visibility(expression) based on pagenumber.
This works fine but it leaves a lot of white space in the first page header as it is hidden. How can I get rid of the whitespaces?
I tried putting those 2 textboxes out of the header, but I'm unable to hide them based on pagenumber, as the pagenumber global variable can be accessed only in header and footer but not from the body.
Is there any other approach to hide these textboxes on first page and show on all other pages?
Thanks in advance.
Update: added similar image

You can't recover the space in the header but you can not use it in the first place and let the text box grow when necessary. The bad part is that when it is exported to Excel, all the text will be in one cell.
Since your text is different sizes, you'll need to use HTML formatting.
In your regular header, add the page formula you are using with the TRUE part containing the text needed for your additional info and the FALSE part with an empty string - "". Use the <br> tag for a page break and the <font> tag to set the size.
="<b>This is My Page Header</b>" & IIF(Globals!PageNumber > 1, "<br><font size = '2'>Text Box 1" & "<br>" & "TextBox 2" & "<font>", "")
You'll need to set the Placeholder properties to Interpret HTML tags.

Related

SSRS Adding fields in report headers/footers

I am wondering if there is a better way to have fields displayed in the report headers and footers. Currently we are doing this by adding the field to a tablix in the report body and referencing that in the header/footer
=ReportItems!ItemName.Value
This however means that there are a lot of hidden fields attached to the main tablix used in the report body and if the end user has to edit the report in the future for whatever reason then it is just confusing and complicated to navigate.
The reason that the fields displayed in the header and footer are attached to the main tablix used in the report body is so that we can take advantage of the grouping and page breaks set there so we can make the header update with different data across different pages within the same report
I know this way works and is probabily one of the easiest to implement but we have a lot of fields that need to be displayed in the headers/footers and the body of the report just looks a mess with lot's of tiny columns in the tablix all hidden. It also makes our tablix quite wide with all of the hidden rows that just make the report it self a lot wider than it should be .
Is this the correct way to do it or is there a better more intuitive way of displaying data in the headers or footers?
I can think of two other ways but normally in the header there should just be a title because its just a header. Everything else can go under the header and formated like you want it (with rectangles and page breaks for example).
So first of all you can use the page numbers to manage different headers. Put a textbox in the header and add the following expression:
=IIF(Globals!OverallPageNumber = 1, "This is the header for Page 1", "This is the header for Page 2")
You can also add a paramater to your report, where you manage different states to manage the headers. In the textbox goes something like:
=IIF(Parameters!HeaderParameter.Value = 1, "Sales haeder", "Work header")
The craziest I did was a header with two key informations:
="Sales Report " & CStr(Year(Now())) & " with an overall amount of " & Parameters!TotalsSales.Value & " EUR"
Everything else should go under the header I think. And if you need to display different tablixes with different information but each of them on a different page. You can add page breaks when you add a rectangle and go to Right click > Rectangle properties > General > Add a page break after.

How to remove Page Header White Space in SSRS report for pages 2..x

We are trying to remove the white space taken up by the Page Header on every subsequent page after page 1. We don't have blank pages, just white space taken up by the header. It also doesn't seem to matter whether we send it directly to the printer or export it to a PDF.
On the Report section, we have set ConsumeContainerWhitespace = True.
On the Page Header section, we have PrintOnFirstPage = True
and PrintOnLastPage = False. Too bad there's not a
PrintOnlyOnFirstPage option!
We have two Rectangles on the Page Header section encompassing all of our header fields, and we've tried setting the Hidden property of these
rectangles to be:
IIF(Globals!PageNumber = 1, False,True).
We have several Text Box fields on the Page Header inside both rectangles. We are turning the visibility attribute of these Text Box fields either on/off depending on whether there's data present in the accompanying data field, e.g. =IIF(Len(First(Fields!SpecialOrderId.Value, "PurchPurchaseOrdersDS")) = 0, True, False).
I've tried the suggestion about putting the header code in the body and programmatically hiding it, but I'm getting this error:
\SSRS Reports\Reports\PurchPurchaseOrder : error AX3026: : PageNumber is invalid. InvalidIdentifier
THECODE:
Public Function PageNumber() As String
Return Me.Report.Globals!PageNumber
End Function
CALLING IT:
=IIF(Code.PageNumber() = "1", False,True)
Thanking you in advance.
Folks, I found a link on a webpage that said: "VB code is no more supported in AX2012-SSRS". Obviously this is why the PageNumber() function does not work for us. However, using Harry's suggestion of moving our header fields into the body of the report fixed our issue and we no longer have two inches of blank white space on pages 2..x! Thanks!

SSRS show the same objects in the second page

I have a Report in SSRS that displays some logos at the top of the first page. I just got a requirement to add the possibility to also show the logos in the second page -- The report is only two pages. Is there a way to repeat the same Image objects in the second page?
If your report is specifically laid out to span multiple pages, you can use a repeating page header. If not (i.e., the second page is caused by content overflow), and you know it will always be two pages or less, you can use a page header and select "print on first page" and "print on last page" in report properties. Otherwise, if you have tablix controls causing the page span, and your page design allows, you can put the logos in the tablix header and enable repeat header on all pages for the tablix. If none of those work, you'll be stuck, as far as I know.
See also this question.
If you are showing Image in the header then you need to following things:
Adding a Data-Bound Image to a Header or Footer
You can use image data stored in a database in a header or footer. However, you cannot reference database fields from the Image report item directly. Instead, you must add a text box in the body of the report and then set the text box to the data field that contains the image (note that the value must be base64 encoded). You can hide the text box in the body of the report to avoid showing the base64-encoded image. Then, you can reference the value of the hidden text box from the Image report item in the page header or footer.
For example, suppose you have a report that consists of product information pages. In the header of each page, you want to display a photograph of the product. To print a stored image in the report header, define a hidden text box named TXT_Photo in the body of the report that retrieves the image from the database and use an expression to give it a value:
=Convert.ToBase64String(Fields!Photo.Value)
In the header, add an Image report item which uses the TXT_Photo text box, decoded to show the image:
=Convert.FromBase64String(ReportItems!TXT_Photo.Value)
http://technet.microsoft.com/en-us/library/dd220421(v=sql.105).aspx
TO repeat image on every page
IN addition to this, to repeat this image into everyt page, Go to property of TXT_Photo textbox In General tab, tick the check box "Repeat report item with data region on every page" and select your region.
Thanks

Force SSRS 2005 to print a new page

I have a field on the footer that may contain more text the the textbox would support. If it does, I need the report to print another page, even if it's completely empty, containing only the footer field.
Basically, if a condition is true, I want the report to print a new page, displaying my footer in it, even if there's nothing else to be printed.
How can I achieve this, preferably with field expressions?
And if you have a solution that's not a field expression (external code for example), could you also point me to the basics of it?
On any block you have the property PageBreak, you can choose begin, end or none. By choosing end, a page break will be insered after the block.
=iif(Globals!PageNumber Mod 2,True,False) this helped me to show (visibility) a text box on even pages only from my footer

How to keep List contents on the first page? (SSRS 2005 - PDF Export)

I've got the following report setup:
1. Letterhead (not in the header, since i only want it on the first page)
2. List control with some data
when i export the report to PDF, and the contents of the List are less that one full page - my letterhead is displayed on the first page (the rest of the page is empty) and the List content gets moved to the second page.
if the List grows over 1 page - reports is showing up just fine (Letterhead and portion of the list on the first page - the rest on the second page)
It looks like it tries to keep the list on 1 page as long as its contents fit on the page - but when you add the letterhead to the contents it overflows the page, and the list gets bumped down to the next page.
Is there any way to keep the list on the first page regardless of its size.
Putting the letterhead in the list is my last resort, I'd like to hear some other solutions.
uploaded a sample .rdl to illustrate the problem
got rid of the list for simplicity, the problem seems to be with a textbox wanting to show up on 1 page
p.s. see this question for more details
What is the source of your text? Is it coming from a dataset? If so, Add a paragraph id in it, set your table to group on the paragraph id and show only the group header. In the group, add a bottom padding value of say 5. The table will handle the paragraph breaks for you, and if it grows more the a page it will handle it for you. Make sure that keep together is set to false. The paragraph id will be used to sort the dataset by id ascending.
sorry I didn't notice your comment at the end. The only other thing that i can think of is to shift your list up closer to the header and eliminate all empty space at the end. Also, make sure the KeepTogether option in the list is set to false. This way it will break up your list rather than move it to the next page.
you can put both the letterhead and the list inside a rectangle so they are always grouped together.
Reporting services also tries to keep the relative spaces you have in the designer, so if you list is aligned to the bottom of the page and there is a space form the header; it will keep the space on top and align everything to the bottom of the page.