I have not posted a blog about Crystal Reports for quite some time, so here is one! More Qlikview next week.
From Crystal Reports 2008 onwards, it is possible to develop a report with both Portrait and Landscape orientated pages and switch between the two as often as required in the same Report.
Setting this up in the Report is easy enough. It is applied on a Section by Section basis in the Section Expert, under the Page tab.
[At the time of writing, it is not possible to control Page Orientation through Formulas.]
So far, so good. But problems emerge regarding formatting when it comes to the Page Headers and Footers.
Let’s look at an example of mixed Orientation messing up a Report, then look at the methods we can use to fix it.
First, page one, a straight forward list of data which fits nicely into a Portrait Orientated Page:
Not the nicest Report, but far from the worst. It is clear and the Page Header and data fit on the Page.
However, if the Client wants a Chart on the second page in Landscape Orientation to give it as much room as possible:
The company name and address still looks ok, but the once centered Title and right justified Logo and Date are now out of place.
When viewed in Design, the problem is much clearer:
All that grey in the top right of the Design view is where the Logo and Date Field should be when the page has Landscape Orientation.
Dealing with Text
If the only problem was the Text Fields, the solution is very simple. It is just a case of copying both the Title and Date Field, and placing the copies in the correct places for the Landscape page.
(I have changed the copy to a grey Font Color for clarity.)
First, the Title: by creating a copy and placing it centrally for the Landscape Page:
Then conditionally Suppress the unwanted Title based on Page Orientation:
It is a very similar solution for the Date Field, but there are a couple of subtle differences.
Firstly, we cannot just place an object directly in that top right grey area. But we can extend the Date Field so it is just hanging onto the report:
There is a small bonus to this method, as only the Portrait Field needs suppressing on the Landscape Page. The Landscape Date is automatically hidden on the Portrait Pages.
This is all there is to handling the Field formatting for multi-Orientated Reports. Unfortunately, there are different rules for Graphics and other similar objects.
Dealing with Graphics
For reasons I do not understand, while moving a Field or Formula off the visible Page of a Report it vanishes, but when the same is done with a Graphic a second page is created to the right of the original page:
Even a suppressed Graphic will have the same effect on the report.
The way to resolve this is to create a new Page Section, duplicate everything in the original Page Header and make the whole thing dependent on the Page Orientation:
The only thing that still needs work is the Logo/Graphic.
A Graphic still cannot be placed wholly in the grey area, nor can it be stretched like the Date Field as it will warp the Graphic.
To get around this, the Graphic has to be extended with enough white space so it can be positioned correctly:
So, in Design view the Report will look like this (I have added a border around the graphic for clarity):
The final report looks like this in Portrait:
And like this in Landscape:
All this may seem like excessive work for the sake of some formatted titles, but creating a report with consistent and professional formatting can be as important as the data itself for keeping the client happy.
We have only looked at the Page Header in this example, but obviously the same techniques can be applied to the Page Footer.
And finally, if anyone would like to hire me to design their company logo after seeing my masterpiece in this chapter, I charge reasonable rates!