Modify Your JSP Report to Display in Microsoft Excel

29-8 Oracle Reports Users Guide to Building Reports 7. The report runs, and the browser displays your report in Microsoft Excel. Your final report output should look something like this: Figure 29–4 Microsoft Excel Output of Your Report

29.5 Summary

You have created Excel output of your report. You now know how to: ■ create a simple paper layout report. ■ modify a Web layout to use an existing paper layout report. ■ test and deploy a JSP-based Web report to Microsoft Excel output using Oracle WebLogic Server. For more information on any of the wizards, views, or properties used in this example, refer to the Oracle Reports online Help, which is available in Oracle Reports Builder or hosted on the Oracle Technology Network OTN, as described in Section 4.1.1, Using the Oracle Reports online Help . Note: The connect string you type in the URL is for the database you used to create the data model in Section 29.2, Create a Query and the Layout . For the purposes of this example, we have used plain text to pass the connect string. For information on using security, refer to the chapter Securing Oracle Reports Services in the Oracle Fusion Middleware Publishing Reports to the Web with Oracle Reports Services manual. Note: If you want your report to display the same colors in Excel as in your report definition, you must use colors supported by the Excel color palette. Otherwise, Excel tries to match unsupported colors, but the match may not be what you expect. Building a Report with Aggregate Data 30-1 30 Building a Report with Aggregate Data In this chapter, you will learn about reports that include aggregate data, based on value ranges. By following the steps in this chapter, you can generate the report output shown in Figure 30–1 . Figure 30–1 Aggregate data report output Concepts In a report that aggregates, or collects, data within ranges, values from the database are retrieved and formatted based on an aggregate range that you define. You can even use parameters to specify the range over which the data should be collected. Data Relationships This report uses two functions in its SELECT statement to specify the aggregate range. The functions are FLOORSAL10001000, which calculates the lowest salary, and CEILSAL+11000 1000, which calculates the highest salary. The columns that receive the values of these functions are placed into a break group to produce the control break format of this example report. Layout This report uses the Group Left layout style. 30-2 Oracle Reports Users Guide to Building Reports Example Scenario In this example, you will build both a paper and JSP-based Web report that collects and displays names of all employees whose salaries fall within the range of 0 to 999, then collects and displays all employees whose salaries fall within the range of 1000 to 1999, and so on. You will be able to modify this report to display any aggregate range you need. As you build this example report, you will: ■ Create a Query and the Layout using the Report Wizard to create a data model and layout for both the paper and Web reports. ■ Modify the Web Source of Your JSP Report to generate the JSP-based Web report. To see a sample report that aggregates data within ranges, open the examples folder named aggregatingdata, then open the Oracle Reports example named aggregatingdata.rdf. For details on how to open it, see Accessing the Example Reports in the Preface.

30.1 Prerequisites for This Example

To build the example in this chapter, you must have access to the SCOTT sample schema provided with the Oracle Database. If you do not know if you have access to this sample schema, contact your database administrator.

30.2 Create a Query and the Layout

The steps in this section will show you how to build a simple data model and report layout in the Report Wizard, which you can then use to generate either a JSP-based Web report or a paper report. In the next section, you will modify the JSP so that the appropriate information displays in your Web report. When you are creating a single-query report, such as this one, you can use the Report Wizard to create the data model and layout simultaneously. To create a data model and layout:

1. Launch Reports Builder or, if already open, choose File New Report.

2. In the Welcome or New Report dialog box, select Use the Report Wizard, then

click OK. 3. If the Welcome page displays, click Next. 4. On the Report Type page, select Create both Web and Paper Layout, then click Next .

5. On the Style page, type a Title for your report, select Group Left, then click Next.

6. On the Data Source page, click SQL Query, then click Next.

7. On the Data page, enter the following SELECT statement in the Data Source

definition field: SELECT FLOORSAL10001000 BOTTOM, CEILSAL+11000 1000 TOP, ENAME, DEPTNO FROM EMP ORDER BY 1,2, SAL