Saturday, February 25, 2012

Report Header woes

I am creating a report which consists of data in two columns. I've set the Body section to have 2 columns in it. This works fine until I start working with the report header. I do not want a page header that shows up on every page, I only want a header on the first page, a report header.

I first tried to hide the header by placing it in the Page Header section, then putting in the "page > 1" expression in the visibility property. This does what I want, except a large blank space is present at the top of my report (the header is about 1.2 "). This is unacceptable.

So my next test was to put the header into the Body section so that it only shows up in the beginning of the report. Because of this, I will need to remove the columns from the Body and make it only 1 column now. I decided to put the multi-column section into a subreport that has 2 columns and add this to the body of my report. But, this failed; the data appears in one column only. I can change the width the ensure it fits and set all other sorts of properties, nothing works.

I've researched both issues and found that these are both "bugs" in reporting services, although I cannot find thedocumented bugs.

Is there any workaround to putting a header onto only the first page of a multi-column report? Other reporting engines are able to handle this with ease, I'm suprised by Reporting Services lack of a "Report Header" section. I am an experienced .NET developer, so if there is a programmatic way through this, I am game.

Thanks,

Scott Steigerwald

I realize this thread is over a year and a half old. The point of this reply is to bring the issue back among the recent posts; a "bump" as it were.

I am struggling with a near identical problem, and have already tried all the workarounds proposed by Mr. Steigerwald, to no avail.

I hope that after 20 or so months, some solution has been discovered.

Thanks,

David Emigh

|||I am pretty confident there is still no solution to this.
I actually faked a multi column report by manipulating the dataset I was pulling across, but this was a failry specific situation where I knew approximately how many rows were always being returned.|||

Thanks.

Sadly, I rather suspected this. At least I know now to look for a solution outside of SQL Reporting Services.

|||

Um, folks... hold on a sec .

I saw the re-post on this question and I think I have succeeded in doing what you want. (Sorry I didn't get around to posting this last night.)

It's a little hacky and it probably won't work for *every* situation, but I did get the basic parameters down:

* -- I've got a Body section with two columns

* -- I have a header that appears to stretch over both areas

* -- it "collapses" after the first page.

Here is what I did:

I couldn't get it to work as a Page header, for reasons you've already discussed. So, instead, I worked out how you could have a Body header that disappeared properly and stretched across.

The first step is to figure out where to put it. In my example, and I am not sure how many other ways there might be to do it, it's a group header and I page breaked on group. I don't think this is relevant, but whatever your data region you need a body element that will be placed at the top of every column.

The background of this page header element should be transparent, because we're going to change its contents for the second column (or more, if it's > 2 cols) and we want it to look as seamless -across as possible.

For the same reason (making the header look seamless-across), you probably want to set the colum spacing as low as possible (you can add some extra padding on the right side by adding an extra blank column, and merge the layout element across, to compensate).

Note that, just as we'll make the contents different for each col, text alignment can be an expression, so using what I"m doing here you could (say) have the left col header left aligned and the right col header right aligned.

I set the expression for this header element to =Code.MyUDF().

You can see my code below. Notice that the ColNo var is incremented each time, so I can use it both for "which column am I in" and "which page am I on".

The tricky part was just figuring out when the Visibility of the element would be evaluated with respect to this function being invoked -- so that I could set the visibility properly. With how I'm doing it here, the visibility expression has to be =Code.ColNo > 1 (one less than you might think, IOW).

The visibility expression would be a little different if I invoked one function to increment earlier, say in an earlier no-height line, and a second function to figure out the expressions to show, but this combined design works okay as well.

I also set the CanShrink property of this element to True to and I set the Visibility of the row to the same expression as the layout element.

Here's the code I used:

Code Snippet

Public ColNo AS Integer = 0


Function MyUDF AS String
Dim myheadpart As String
ColNo = ColNo + 1
If ColNo = 1
myheadpart= "1st part of header"
ElseIf ColNo = 2
myheadpart= "2nd part"
Else
myheadpart = ""
End If
Return myheadpart
End Function

... HTH,

>L<

|||

Thank you!

I've bookmarked this thread for future reference, as this situation will almost certainly come up again.

Unfortunately, in my particular situation, it doesn't seem applicable. I have a requirement to include an image that is wider than the the sum of the widths of the first column and the space between it and the second. The image has a minimum size and a non-negotiable aspect ratio.

I wasn't the thread starter on this one, but if I were, I would mark this as "answered"

Thanks again,

David

|||

Hi David

I see what you mean about the image -- I know this whole idea is a bit dodgy but there might be some way to split the image up into two? First make a "full image" the full width of the page, I mean with a lot of filler-empty space on the right (or on both sides, if you're trying to center it horizontally on the page), and then split it down the middle for column one and column two. No guarantees that it will work, of course, but worth a shot?

>> I would mark it

Well, I can mark it as a moderator but I won't <g>. I won't do that with my own answers unless they prove out (actually help somebody) <g>.

>L<

|||

Maybe I am misundertanding things but generally when I want a first page only header I create a second dataset that returns a single record by using a statment like "select x=1". Then I just use a table set to the dummy header at the top of my body section. A typical example where I would use it is for invoices.

|||

Lisa,

Perhaps another moderator will come along and do the deed which modesty prevents you doing yourself

My manager has decided on a different approach to this problem, one which precludes any image editing, but I will keep that in mind also.

David

|||

Hi there,

Yeah, a first page header *alone* is not the problem here. (There are lots of ways to do that -- for example you can group on something that will never break as an outer group...)

The problem we're trying to solve here is the multi-column report and getting the page header to stretch across those columns without using a page header...

>L<

|||

Hi David,

If you don't mind my asking... what did you and your manager settle on? (It's always good to be able to remove the requirement if the requirement is a PITA <rofl>)

>L<

|||

Hey Lisa,

The requirement didn't go away, we just opted to generate the report header and report body separately, then merge them later (probably as an active .pdf via a web app).

|||

Ah.

Well, good to know. (I have posted about combining files in a PDF a couple of times, and recently found a nice utility for this to complement my usual low-level ghostcript PDF approach... give a shout if you have a difficulties.

FWIW there are many reasons to do this that have nothing to do with your current problem, for example different orientation of a cover page. Repeat after me: a report is a document section, not a document. Extended essay on this subject here: http://spacefold.com/lisa/post/Reporting-Convergences-Chapter-The-one-about-multiple-sets-of-printing-instructions.aspx.

>L<

No comments:

Post a Comment