29.4 Modify Your JSP Report to Display in Microsoft Excel

Now that you have created your JSP-based Web report, which looks the same as your paper report, you will modify it further to display the report in Microsoft Excel in your Web browser.

First, copy myexcelreport_your_initials.jsp to the deployment directory of your Application Server. For testing purposes, in this example, we will use the Oracle WebLogic Server instance shipped with the Oracle Developer Suite.

For more information on deploying a JSP-based Web report, refer to the "Deploying Your Reports" section in Publishing Reports to the Web with Oracle Reports Services.

To modify the report to display in Microsoft Excel:

  1. In the Report Editor, click the Web Source button in the toolbar to display the Web Source view.

    In the Web Source view, you will change the content type of the HTTP response using the JSP directive contentType, so that the browser opens Microsoft Excel to display your report output.

  2. In the Web Source view, find the following text:

    <%@ taglib uri="/WEB-INF/lib/reports_tld.jar" prefix="rw" %>
    <%@ page language="java" import="java.io.*" errorPage="/rwerror.jsp"
    session="false" %>
    <%@ page contentType="text/html;charset=ISO-8859-1" %>
    <rw:report id="report">
    <rw:objects id="objects">
    </rw:objects>
    ......
    ......
    <!--
    </rw:report>
    -->
    

    and modify it to read as follows:

    <%@ taglib uri="/WEB-INF/lib/reports_tld.jar" prefix="rw" %>
    <%@ page language="java" import="java.io.*" errorPage="/rwerror.jsp"
    session="false" %>
    <%@ page contentType="application/vnd.ms-excel;charset=ISO-8859-1" %> 
    <rw:report id="report">
    <rw:objects id="objects">
    </rw:objects>
    ......
    ......
    <!--
    </rw:report>
    -->
    
  3. Save your report.

  4. Copy the Web report (myexcelreport_your_initials.jsp)into the following directory:

    $DOMAIN_HOME/servers/<managed_server_name>/tmp/_WL_user/reports_<version>/<dir_name>/web.war
    
  5. Start your Oracle WebLogic Server instance to enable the deployment of your report.

    • On Windows, you can do either of the following:

      • From the Start menu, choose Programs > Oracle Classic Instance > Reports Services > Start WebLogic Server - WLS_REPORTS.

        For example, the Oracle Classic Instance may be Oracle Classic Instance-asinst_1.

      • From the command line, run the following command:

        cd $DOMAIN_HOME\bin\startManagedServer.bat WLS_REPORTS

    • On UNIX, start the shell script from the command line:

      • $DOMAIN_HOME\bin\startManagedServer.sh WLS_REPORTS

    Tip:

    The Oracle WebLogic Server instance starts once the containers for Java EE have been initialized.
  6. Type the following URL to display your report in Microsoft Excel in your Web browser:

    http://your_computer:port/reports/yourexcelreportname.jsp?userid=hr/hr@db
    

    In our example, we use:

    http://mycomputer-pc:8888/reports/my_excel_report.jsp?userid=hr/hr@orcl
    

    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 "Securing Oracle Reports Services" chapter in Publishing Reports to the Web with Oracle Reports Services.
  7. The report runs, and the browser displays your report in Microsoft Excel.

    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.

    Your final report output should look something like this:

    Figure 29-4 Microsoft Excel Output of Your Report

    Description of Figure 29-4 follows
    Description of ''Figure 29-4 Microsoft Excel Output of Your Report''