Creating PDF Reports with Oracle Application Express 3.1

Purpose

This tutorial shows you how to use some of the new features on PDF Reporting in Oracle Application Express 3.1.

Time to Complete

Approximately 30 minutes

Topics

This tutorial covers the following topics:

 Overview
 Prerequisites
 Creating a Standard PDF Report
 Creating a PDF Report from Derived Output Format
 Creating a PDF Report with Multiple Source Queries
 Creating a PDF Report with a Report and Chart
 Summary
 Related Information

Viewing Screenshots

 Place the cursor over this icon to load and view all screenshots for this tutorial. (Caution: This action loads all screenshots simultaneously, so response time may be slow depending on your Internet connection.)

Note: Alternatively, you can place the cursor over an individual icon in the following steps to load and view only the screenshot associated with that step. You can hide an individual screenshot by clicking it.

Overview

Report Queries now support multiple SQL statements, which allows for including multiple reports in a single document or combining reports and charts based on different result sets. The output format of a print document can now be set at runtime using a page or application item. In addition to PDF, Word, Excel and HTML, documents can now also be downloaded in XML format. Both report queries and report regions now allow specifying the method of how the print document is downloaded to the client, either as an attachment, displaying a file download / save dialog or showing the document inline within the browser window. The column sizing for print documents based on report regions has also been improved, now supporting sizing based on points in additional to percentage. For further information, click on help and search on Printing.

To get more information about the 3.1 New Features, click here.

Back to Topic List

Prerequisites

Before you perform this tutorial, you should:

1.

Install Oracle Database 9.2.0.3 or above.

2.

Download and Configure Oracle Application Express 3.1.

3.

Download the OEHR Sample Objects Packaged Application here. Import and install the application and its supporting objects into your Oracle Application Express 3.1 instance.

4.

Download and unzip the apexnf.zip file which contains the report layout RTF files necessary to create some of the reports in this tutorial.

5.

To perform this tutorial, you need to perform the Building and Customizing an Interactive Report in Oracle Application Express 3.1 and Defining and Viewing BLOB Data in Oracle Application Express 3.1 tutorial. Alternatively, you can import the OBE New Features application as a packaged application in Application Express. Download and unzip the apexnf.zip file and import the blobobe_packagedapp.sql packaged application file.

Note: This tutorial provides the RTF files necessary to create the Report Layouts. If you would like to learn how to create an RTF template, you can perform the Utilizing Advanced Printing in Oracle Application Express 3.0 tutorial or review the documentation chapter How to Create a Master Detail PDF Report.

Back to Topic List

Creating a Standard PDF Report

In Oracle Application Express 3.1, you have more control over the output in a standard PDF report. Perform the following steps:

1.

Login to Application Express and navigate to your New Features Application. Click the Maintain Employee Information report page.

 

2.

Under Regions, select the Report link.

 

3.

Click the Print Attributes tab.

 

4.

Select Yes for Enable Report Printing and Inline for View File As and click the Report Columns tab. If Attachment is selected for View File As, a file open / save dialog appears when you click the report download link. In Oracle Application Express 3.1, you can now select Inline which displays the report document directly inside the browser window. This selection is included in the http header of the document using the content-disposition attribute.

 

5.

Deselect the check box for Include in Export for the PHOTO column and click Recalculate.

 

6.

Note that the spacing of all the columns included is distributed equally. You can manually change the numbers. Click Apply Changes.

 

7.

Click Run Page.

 

8.

Select the Print link at the bottom of the report.

 

9.

The PDF report is displayed. To return to the Report in Application Express, click the Back button in your browser.

 

10.

In the next section, you derive the output format based on a select list. Select the Edit Page link in the developer toolbar.

 

Back to Topic List

Creating a PDF Report from Derived Output Format

In order to derive the output format, you need to create an item that contains the list of formats to select from. Perform the following steps:

1.

Under Items, click the Create icon.

 

2.

Click Select List.

 

3.

Make sure Select List is selected for Select List Control Type and click Next.

 

4.

Change the Name to P<#>_OUTPUT_LIST and click Next.

 

5.

You need to specify the list of output types for the report and the bottom of the page. Select the Create or edit static List of Values link.

 

6.

Enter the following values and click Apply.

Display Value Return Value
PDF PDF
Word RTF
Excel XLS
HTML HTM
XML XML

 

7.

Select No for Display Null Option and Click Next.

 

8.

Change the Label to Output Format and click Next.

 

9.

Enter PDF for the Default and click Create Item.

 

10.

Now that the list of output formats is created, you need to change the Output Format when the Print link is selected. Under Regions, select the Print link.

 

11.

Under Printing, select Derive from Item for Output Format and select the item you just created P<#>_OUTPUT_LIST for Item and click Apply Changes.

 

12.

Click Run Page.

 

13.

When the report is displayed, select Excel from the list of Output Formats. Note: In Oracle Application Express 3.1, the XML format was added.

 

14.

At the bottom of the report, select the Print link.

 

15.

A window appears asking you which program you want to open the Excel file with. Click OK (or Open depending on what browser you have) . Excel is open and the report is displayed. Close the Excel window.

 

16.

You can also create a button to produce the report based on the output format rather than clicking the Print link at the bottom of the report. Click Edit Page.

 

17.

Under Buttons, click the Create icon.

 

18.

Accept the default and click Next.

 

19.

Select Create a button displayed among this region's items and click Next.

 

20.

Enter P<#>_Print for the Button Name, enter Print for the Label and Request and select HTML Button for Button Style. Then click Create Button.

 

21.

The region printing link contains the id of the region. Since you want to invoke the print from a button instead of the link you need to create a branch and specify the FLOW_XMLP_OUTPUT_R### parameter in the Request field for the Action so the application knows what to do when the Print button is pressed. Under Regions, select the Print link.

 

22.

Ctrl-C the FLOW_XMLP_OUTPUT_R### section of the Print URL field. Since you are going to invoke the print from the button, you can remove the Print in the Label Link field and click Apply Changes.

 

23.

Under Branches, select the Create icon.

 

24.

Accept the default and click Next.

 

25 .

Enter the current page for the Page and paste the FLOW_XMLP_OUTPUT_R### parameter that you copied into the Request field and click Next.

 

26 .

Select P<#>_PRINT for When Button Pressed and click Create Branch.

 

27 .

Click Run Page.

 

28 .

Select XML for the Output Format and click Print.

 

29 .

The XML is displayed.

 

Back to Topic List

Creating a PDF Report with Multiple Source Queries

You can add multiple queries to a PDF Report in Oracle Application Express 3.1. Perform the following steps:

1.

Navigate to the New Features Application page. Click Shared Components.

 

2.

Under Reports, select Report Queries.

 

3.

Click Create.

 

4.

Enter multiquery for the Name and click Next.

 

5.

Enter the following query and click Next.

select      "OEHR_EMPLOYEES"."FIRST_NAME" as "FIRST_NAME",
                              
"OEHR_EMPLOYEES"."LAST_NAME" as "LAST_NAME",
"OEHR_EMPLOYEES"."EMAIL" as "EMAIL",
"OEHR_EMPLOYEES"."HIRE_DATE" as "HIRE_DATE",
"OEHR_EMPLOYEES"."SALARY" as "SALARY"
from "OEHR_EMPLOYEES" "OEHR_EMPLOYEES"
where "OEHR_EMPLOYEES"."JOB_ID" like 'IT_PROG' order by "OEHR_EMPLOYEES"."LAST_NAME"

 

6.

You want to perform multiple queries, click Add Query.

 

7.

Enter the following query and click Create.

select      "OEHR_DEPARTMENTS"."DEPARTMENT_NAME" as "DEPARTMENT_NAME",
                              
"OEHR_EMPLOYEES"."FIRST_NAME" as "FIRST_NAME",
"OEHR_EMPLOYEES"."LAST_NAME" as "LAST_NAME",
"OEHR_LOCATIONS"."CITY" as "CITY",
"OEHR_LOCATIONS"."STATE_PROVINCE" as "STATE_PROVINCE"
from "OEHR_LOCATIONS" "OEHR_LOCATIONS",
"OEHR_EMPLOYEES" "OEHR_EMPLOYEES",
"OEHR_DEPARTMENTS" "OEHR_DEPARTMENTS"
where "OEHR_DEPARTMENTS"."MANAGER_ID"="OEHR_EMPLOYEES"."EMPLOYEE_ID"
and "OEHR_DEPARTMENTS"."LOCATION_ID"="OEHR_LOCATIONS"."LOCATION_ID" order by "OEHR_DEPARTMENTS"."DEPARTMENT_NAME"

 

8.

Your queries have been defined. Click Next.

 

9.

The Report Layout has already been defined for you in the apexnf.zip file provided in the prerequisites. You just need to upload the file. Click Browse... select the multiquery.rtf file and click Open.

 

10.

Click Next.

 

11.

Click Test Report.

 

12.

Click OK to open the file to view the report.

 

13.

The Report is displayed. Both queries are executed and displayed using the Report layout that was previously defined. Close the window.

 

14.

Click Finish.

 

15.

Your report query was created successfully. You can now associate it with your page in your application. Click the Application breadcrumb.

 

16.

Select the Maintain Employee Information page.

 

17.

You will create a button to run the report. Under Buttons, click the Create icon.

 

18.

Accept the default and click Next.

 

19.

Accept the default to Create a button in a region position and click Next.

 

20.

Enter Employee Manager Report for the Name and select Download Printable Report Query for Action and click Next.

 

21.

Accept the default and click Next.

 

22.

Select [Top] and click Next.

 

23.

Select multiquery for Report Query and click Create Button.

 

24.

Click Run Page.

 

25.

Click the button Employee Manager Report.

 

26.

Click OK to open the PDF file.

 

27.

The report is displayed. Close the window. In the next section, you create a report and chart.

 

Back to Topic List

Creating a PDF Report with a Chart

In this section, you create a report with a chart. For simplicity purposes, an RTF file has been provided with the Report Layout. In order to create a report layout from scratch, you need to install Oracle BI Publisher Desktop and create the layout in Microsoft Word. The OBE Utilizing Advanced Printing in Oracle Application Express 3.0 provides the steps to create a report layout from scratch. Perform the following steps:

1.

Navigate to the New Features Application page. Click Shared Components.

 

2.

Under Reports, select Report Layouts.

 

3.

Click Create.

 

4.

Select Named Columns (RTF) and click Next.

 

5.

Enter reportwchart for the Layout Name and select the reportwchart.rtf file provided in the zip file in the prerequisites. Then click Create Layout.

 

6.

Click the Shared Components breadcrumb.

 

7.

Under Reports, select Report Queries.

 

8.

Since there are only a couple of changes between the multiquery report query and the report and chart query, you can copy the existing one. Click Copy.

 

9.

Select multiquery for Copy Report Query and enter reportwchart for the Report Query Name and click Copy.

 

10.

You need to change the query for the chart and the report layout. Select the reportwchart report query.

 

11.

Select reportwchart for Report Layout and select the Source Queries tab.

 

12.

The first query remains the same which is the first report. You need to change the second query. Click the Edit icon in front of the second query..

 

13.

Change the query to the following code and click Apply Changes.

select       "OEHR_DEPARTMENTS"."DEPARTMENT_NAME" as "DEPARTMENT_NAME",
                              
"OEHR_EMPLOYEES"."SALARY" as "SALARY"
from "OEHR_EMPLOYEES" "OEHR_EMPLOYEES",
"OEHR_DEPARTMENTS" "OEHR_DEPARTMENTS"
where "OEHR_DEPARTMENTS"."MANAGER_ID"="OEHR_EMPLOYEES"."EMPLOYEE_ID"

 

14.

Click Test Report.

 

15.

Click OK to open the PDF report.

 

16.

The report and the chart are displayed. Close the window.

 

17.

Click Apply Changes.

 

18.

Select the Application breadcrumb.

 

19.

Select the Maintain Employee Information report page.

 

20.

Under Buttons, click the Create icon.

 

21.

Accept the default and click Next.

 

22.

Accept the default to Create a button in a region position and click Next.

 

23.

Enter Salary by Department for the Name, select Download Printable Report Query for Action and click Next.

 

24.

Accept the default and click Next.

 

25.

Select [Top] and click Next.

 

26.

Select reportwchart for Report Query and click Create Button.

 

27.

Click Run Page.

 

28.

Click the button Print Report with Chart .

 

29.

Click OK to open the PDF file.

 

30.

The report is displayed.

 

Back to Topic List

Summary

In this tutorial, you learned how to:

 Create a standard PDF report
 Create a PDF report from derived output format
 Create a PDF report with multiple source queries
 Create a PDF report with a report and chart

Back to Topic List

Related Information

To learn more about Application Express, you can review the following:

Related Documentation

Description

Online Help

To access this help, click the Help button displayed in the top right corner of Application Express. Search on topics of interest.

Release Notes

These notes contain important information not included in the Oracle Application Express documentation.

Installation Guide

This guide explains how to install and configure Oracle Application Express.

2 Day + Developer’s Guide

This guide shows you how to set up a development environment or access a hosted demonstration environment to use with this guide. It then walks you through building an initial application, modifying it, and previewing it.

User’s Guide

This guide describes how to use the Oracle Application Express development environment to build and deploy database-centric Web applications. Oracle Application Express turns a single Oracle database into a shared service by enabling multiple workgroups to build and access applications as if they were running in separate databases.

Advanced Tutorial

Tutorials with step-by-step instructions that explain how to create a variety of application components and entire applications using the Oracle Application Express development environment.

Back to Topic List

 Place the cursor over this icon to hide all screenshots.

 

 

 

Left Curve
Popular Downloads
Right Curve
Untitled Document