18
Building a Report with Graphics, Text, and Color
Figure 18-1 Graphics, text, and color report output
Text description of the illustration orbrgraphics_fin.gif
Reports Builder enables you to modify the look of your report in multiple ways. In this example, you will build a report and enhance it by adding an image to the margin, a title, and a border. You will also change the look of the report by applying different fonts and text styles.
Concepts
This report shows you how to enhance your reports with graphics by:
- using the Paper Layout view's drawing tools.
- highlighting boilerplate text appearing in the output.
- using different colors (if available) and patterns for boilerplate text.
For more information on enhancing the appearance of your reports, refer to the Reports Builder online help.
Reports Builder enables to you to manipulate the appearance of your report on the fly. If you intend to reuse the look and feel of your report, you can always create a template and add it to your template library. You can find out more information about using templates in Getting Started with Oracle Reports (http://otn.oracle.com/products/reports/
).
Data Relationships
- This is a one-query group left report.
Layout
- This report uses a Group Above layout, which you'll modify in the Paper Layout view to make room for the title and company logo. Then, you'll import the logo, create the report title, and the rest of the graphics shown in the image above.
Example Scenario
In this example, you'll create one query that selects all the columns for this report. You'll also assign a column to a new break group.
To see a sample report with graphics and highlighted text, open the examples folder named graphics
, then open the Oracle Reports example named graphics.rdf
. For details on how to open it, see "Accessing the example reports" in the Preface.
Table 18-1 Features demonstrated in this example
18.1 Prequisites for this example
To build the example in this chapter, you must have access to the sample schema provided with the Oracle9i database. If you don't know if you have access to this sample schema, contact your database administrator. You should have access to the "Human Resources" portion of the schema to complete this example.
18.2 Create a simple report definition
When you create a report, you can either use the Report Wizard to assist you or create the report yourself. In this example, you will use the Report Wizard to create your query and basic report layout.
To create the report definition:
- Launch Reports Builder (or, if already open, choose File > New > Report)
- In the Welcome or New Report dialog box, select Use the Report Wizard, then click OK.
- If the Welcome page displays, click Next.
- On the Report Type page, select Create Paper Layout Only, then click Next.
- On the Style page, type a Title for your report, select Group Above, then click Next.
- On the Data Source page, click SQL Query, then click Next.
- On the Data page, enter the following SELECT statement in the Data Source definition field:
SELECT ALL DEPARTMENTS.DEPARTMENT_ID, EMPLOYEES.FIRST_NAME, EMPLOYEES.LAST_
NAME, EMPLOYEES.JOB_ID, EMPLOYEES.SALARY, JOBS.JOB_TITLE
FROM DEPARTMENTS, EMPLOYEES, JOBS
WHERE ((DEPARTMENTS.DEPARTMENT_ID = EMPLOYEES.DEPARTMENT_ID)
AND (EMPLOYEES.JOB_ID = JOBS.JOB_ID))
ORDER BY DEPARTMENTS.DEPARTMENT_ID
Note:
You can enter this query in any of the following ways:
- Copy and paste the code from the provided text file called
graphics_code.txt into the Data Source definition field.
- Click Query Builder to build the query without entering any code manually.
- Type the code in the Data Source definition field.
|
- Click Next.
Note:
If you are not already connected to a database, you will be prompted to connect to the database when you click Next. Ensure that you connect to a database that has the appropriate schema for this example. Section 18.1, "Prequisites for this example" describes the sample schema requirements for this example.
|
- On the Groups page, click DEPARTMENT_ID and click the right arrow (>) to move this field to the Group Fields list, then click Next.
- On the Fields page, move all fields except JOB_ID to the Displayed Fields list, then click Next.
- On the Totals page, click Next.
- On the Labels page, change the label Department Id to
Department
, then click Next.
- On the Template page, select Predefined Template and click Blue, then click Finish to display your report output in the Paper Design view. It should look something like this:
Figure 18-2 Paper Design view for the graphics report with one query
Text description of the illustration orbrgraphics_pap.gif
18.3 Modify the report in the Paper Layout view
The steps in this section show you how to use the various tools in the Paper Layout view to modify the appearance of your report. First, you will move the existing frames to accommodate the changes you will make. You will then add a title to your report, borders around each record, and change the text color.
To modify your report:
- Click the Paper Layout view button in the toolbar to display the Paper Layout view.
- Make sure the Confine On button in the toolbar is set to Confine mode on. Doing so allows you to move the objects in the Paper Layout view around the canvas.
- In the Object Navigator, under Paper Layout > Body, click the item M_G_DEPARTMENT_ID_GRPFR.
Notice that, in the Paper Layout view, the outermost frame is selected.
- Click on the frame in the Paper Layout view and drag it about two inches down and one inch to the right.
You can use the rulers along the sides of the Paper Layout view as guidance. Your Paper Layout should now look something like this:
Figure 18-3 Paper Layout View of Adjusted Report Layout
Text description of the illustration orbrgraphics_lay.gif
- Now, make sure Flex mode is on and click the Confine Off button in the toolbar to set Confine mode off.
- Make space for the border you will create that will surround each record. In the Object Navigator, select M_G_DEPARTMENT_ID_GRPFR again.
- Drag each corner to make space around the inner repeating frame, so that the layout now looks like the following image. Notice the white space around the groups.
Figure 18-4 Paper Layout View with Expanded Repeating Frame
Text description of the illustration orbrgraphics_lay1.gif
- Now, let's make space between each record so that we can later put a horizontal line between the records. In the Object Navigator, click R_G_DEPARTMENT_ID.
- In the Paper Layout view, click the bottom right corner and drag it down about 0.5 inches so that your layout now looks like this:
Figure 18-5 Paper Layout View with Expanded R_G_DEPARTMENT_ID Repeating Frame
Text description of the illustration orbrgraphics_lay2.gif
- Save your report as
graphics_<your initials>.rdf
.
18.3.1 Adding a border around the report
Now that you've set up your layout, you can start adding new items. In this section, you will add a border around the entire report.
To add a border:
- In the Object Navigator, select the M_G_DEPARTMENT_ID_GRPFR frame.
- In the Paper Layout view, while the M_G_DEPARTMENT_ID_GRPFR frame is selected, click the Line Color tool. The tool can be found at the very bottom of the tool palette.
- In the color palette that displays, choose the black square to make the border black.
- While the line is still selected, choose Format > Line > Line Width > 2 pt.
- Now, preview the layout. In the toolbar, click the Paper Design button in the toolbar to run the report to paper. It should look something like this:
Figure 18-6 Preview of the Report with a Border
Text description of the illustration orbrgraphics_border.gif
- Save your report as
graphics_<your initials>.rdf
.
18.3.2 Change the font size and style
In the Paper Layout view, you can also change the font and style of the text. The steps in this section will show you how to modify the Department Number text.
To change the font:
- In the Paper Layout view, click the Paper Layout button in the toolbar.
- In the Object Navigator, select the B_DEPARTMENT_ID and F_DEPARTMENT_ID fields so that you can change the font of the Department ID label and text.
Note:
B_DEPARTMENT_ID refers to the boilerplate text "Department ID", which serves as the label for the F_DEPARTMENT_ID field.
|
- Click on the title bar of Paper Layout view to make it the active window.
- While the two fields are selected, choose Format > Font.
- In the Font dialog box, choose a different font and size. In the example, we chose Times New Roman and 12 pt.
Note:
Depending on the font and font size you choose, you may have to adjust the size of the fields to accommodate the text. In the example, since the font was increased, we selected the boilerplate text field and enlarged it.
|
- When you've finished your changes, click OK.
- Display your report in the Paper Design view to see what it looks like. Here's an example:
Figure 18-7 Paper Design View of the Report with New Fonts
Text description of the illustration orbrgraphics_font.gif
- Save your report as
graphics_<your initials>.rdf
.
18.3.3 Add bullets your report
The steps in this section will show you how to add bullets so that a bullet displays next to each department ID.
To add bullets to your report:
- In the Paper Layout view, make sure you have enough space next to the B_DEPARTMENT_ID field where you can add a bullet. The bullet needs to be within the R_G_DEPARTMENT_ID repeating frame so that it displays for each record.
- Click the Ellipse tool in the tool palette.
- Press the SHIFT key, then draw an ellipse next to the boilerplate text "Department."
Note:
Pressing the SHIFT key while you draw the ellipse puts the tool in a "constrained" mode. When you create an ellipse in this mode, you can create a circle. Other tools are similar; for example, constraining the Rectangle tool creates a square. For more information on using these tools, refer to the Reports Builder online help.
|
- You should now see a circle in the repeating frame. To make the bullet a solid color, select the circle, then click the Fill Color tool in the tool palette.
- In the color palette that displays, choose black.
- Run your report to the Paper Design view to see what it looks like.
Note:
When you're checking your layout, make sure that the ellipse displays within the R_G_DEPARTMENT_ID repeating frame.
|
Figure 18-8 Paper Design View of the Report with Bullets
Text description of the illustration orbrgraphics_bullet.gif
- Save your report as
graphics_<your initials>.rdf
.
18.3.4 Display a line between each record
When you have a lot of data, you sometimes want to further distinguish each record, so that it's clear how the information is related. In this section, you will add a horizontal line to the layout that will display between each department record.
To add a line separator:
- In the Paper Layout view, click the Line tool in the tool palette.
- Press the SHIFT key, then draw a line in the R_G_DEPARTMENT_ID frame beneath the fields, like this:
Figure 18-9 Paper Layout View with Line Separator
Text description of the illustration orbrgraphics_layline.gif
- Format the line the way you want to appear. In our example, we chose Format > Line Width > 2 pt. Then, we changed the color to black.
- Run your report to the Paper Design view. It should now looks something like this:
Figure 18-10 Paper Design View of Report with Line Separator
Text description of the illustration orbrgraphics_papline.gif
- Save your report as
graphics_<your initials>.rdf
.
18.3.5 Add a title to your report
The steps in this section will show you how to use the tools in the tool palette to create a title for your report. You will use the Fill Color to create a black background and white text, as well as arrange your items so they display properly.
To add a title to the report:
- In the Paper Layout view, click the Text tool in the tool palette.
- Draw a rectangle where you want the title to display. We drew the rectangle above the repeating frames, so that the title would display once, above all the data.
- In the new rectangle object, type a title, such as "
Employee Details
."
- Click the Fill Color tool in the tool palette, and choose black.
- Click the Text Color tool and choose white.
- Click the Rectangle tool, and draw a rectangle around the text.
- When you are done, click the Fill Color tool and choose black. Notice how you don't see the text anymore.
- In the Object Navigator, find the text object you created under Body. You can tell which objects are text objects by the A icon next to the name. In our case, the text object is B_3.
- Once you've selected the object, click the title bar of the Paper Design view to select the Paper Design view.
- Choose Layout > Bring to Front.
- Run your report to the Paper Design view. It should now look something like this:
Figure 18-11 Paper Design View of Report with Title
Text description of the illustration orbrgraphics_title.gif
- Save your report as
graphics_<your initials>.rdf
.
18.4 Summary
Congratulations! You have successfully created a paper report and modified the text color and fill colors, as well as added graphics. You now know how to:
- use the Report Wizard to create a simple report definition.
- modify the layout of the objects in your report.
- add a border to the report.
- add bullets to each record.
- add a horizontal separator between each record.
- add a title to your report using fill colors and layout features.
For more information on any of the wizards, views, or properties used in this example, refer to the Reports Builder online help, which you can access in two ways: