Anda di halaman 1dari 2

Let's assume that there is a report that is very wide as well as long.

It is decided that
horizontal pagination will be used so that the report is printed over multiple A4 sheets with
big readable fonts. However, when this report is printed, it is very difficult for the users to
understand how they stitch together horizontally, and when actually a new page starts.
Let's see how to solve this issue using appropriate page numbering.
Getting ready
Open the Sales report with horizontal pagination prepared in the previous recipe.
How to do it...
We want to modify the report that we created in the previous recipe to include page numbers
so that it can be easier for users to work with the report. We can do this by changing the
properties of the report page as we will see in the following steps:
1. Click anywhere on the report page and choose PAGE from the Select Ancestor
Properties pane.
Writing Printable Reports
148
2. Open the Pagination property and check the Enable horizontal page numbering
option as shown in the following screenshot:
3. By default, there will be a Page Number object in Page Footer. If you can't find it,
you can insert a new Page Number object from the toolbox.
4. Select this Page Number object and from its Properties, choose Number Style as
1-a as shown in the following screenshot:
5. Now run the report to see how page numbers appear in the footer. Notice that for the
first page split over multiple sheets, the footer displays 1-a, 1-b, 1-c, and so on. When
the next report page starts, the numbering changes to 2-a, 2-b, 2-c, and so on.
How it works...
By enabling horizontal page numbering, we are making sure that Cognos generates
appropriate page numbers with subsections to clearly show how pages are split over
multiple sheets horizontally.
Chapter 6
149

Choosing the output format from a prompt


After all of the previous recipes, you must have understood by now that reports need to be
generated in the PDF format for printing purposes.
The default output format is HTML, which is good for interactive reports with drill-downs and
drill-throughs. However, it is not printer friendly. They would see one page of output at a time
with navigation links at the bottom of the screen, and hence printing the whole report is not
straightforward. For printing, users need to run the report in PDF format. Clicking on the PDF
icon resubmits the report query and users have to wait for the execution to finish.
It will be handy to control the report output from a prompt page. In this recipe, we will add a
prompt control which asks users to specify the output format. This way, users can think of
the application beforehand (interactive, printing, analysis, and so on) and decide whether
the output should be HTML, PDF, Excel, or something else.
Getting ready
We will use the list report that we created in the previous recipe.
How to do it...
In this recipe, we will use JavaScript to create the required prompt as we can see in the
following steps:
1. Open the report in Report Studio.
2. Add a new prompt page to the report from Page Explorer.
3. Open the prompt page and insert a new HTML item in the page body.
4. Define the HTML item as follows:
<html>
<head>
<script language="javascript">
function gotoUrl()
{var obj=document.all['OutputFormat'];
/* Below function passed the selected output format to the server
*/
window.onload(gCognosViewer.getRV().viewReport(obj.options[obj.
selectedIndex].value));
}
</script>
</head>
<body>
<!-- Below will create a dropdown with choices -->
Writing Printable Reports
150
<select name="OutputFormat" OnBlur="javascript:gotoUrl()">
<option value="HTML">HTML</option>
<option value="PDF">PDF</option>
<option value="singleXLS">Excel 2000 Single Sheet</option>
<option value="spreadsheetML">Excel 2007</option>
<option value="XLWA">Excel 2002</option>
<option value="XLS">Excel 2000</option>
<option value="CSV">Delimited text (CSV)</option>
<option value="XML">XML</option>
</select>
</body>
</html>
5. Run the report to test it as shown in the following screenshot:
How it works...
This script displayed various output format options in a dropdown. Whatever is selected by
the user is passed to the viewer application. This way, we can control the output format
from a prompt page.

Anda mungkin juga menyukai