# Reporting Process Overview

This chapter describes an overview of each phase of the report development process:

1. Creating the initial report

   To create a new report, use the Report Wizard. Reports can also be built piece-by-piece instead of by using the wizard, or a report can be created based on an existing report.

   For more information, see Creating a report.

2. Fine-tuning the report

   You can arrange the layout as required. Or you can use the Report Inspector to modify the report objects created by the Report Wizard. Properties and values of all objects in a report are displayed in a property sheet for you to view and change interactively. The properties for different objects in Report Inspector will be displayed dynamically. See Properties in the Report Inspector for details about each object's properties. In addition, many properties can be controlled dynamically by using a formula. See Using formulas to control object properties for more information.

3. Testing the report

   While developing your report, you can test it any time to preview the result. For more information, see Previewing a report.

4. Exporting the report

   JReport Designer can export report results to various formats such as Text, HTML, PDF, PostScript File, Mail, Applet, Excel File and Fax. To export the report, use File > Export To.

   See Exporting report results for more information.

5. Publishing the report

   When your report is ready to be published, you will need access to the JReport Enterprise Server in the runtime environment. If the JReport Enterprise Server is accessible from the host on which JReport Designer is running, you can publish from JReport Designer. Otherwise, you will need to copy the catalog and report template to the host on which the JReport Enterprise Server is running and perform the publishing process from the JReport Enterprise Server.

   See Publishing Resources for more information about publishing reports from JReport Designer.

This chapter also describes an overview of using the JReport APIs to develop a report in the following topic:

## Developing a report programmatically

As described above, a report is developed and tested with JReport Designer, saved as a .cls file, and then published to an instance of JReport Enterprise Server. The process can also be achieved from within a Java application by using the Designer API, JReport Engine Bean, and JReport Result Viewer Bean as follows:

### JReport Designer API

    import java.io.*;
    import java.awt.*;

    import jet.api.*;
    import jet.jetc.*;
    import jet.universe.exception.*;

    DesignerUserInfo userInfo=new
    DesignerUserInfo("Uid","XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX");
    Designer desg   = new Designer(path, cat, userInfo);
    desg.setLog(new FileOutputStream(log), "8859_1");

    //Opening an Existing Report
    report = desg.open(name);

    //Getting Handles
    handle = desg.getHandles(report, Designer.IMAGE)[0];

    //Changing the Property Value
    //Change the image "coffee.gif" to "ship-logo.gif"
    desg.set(handle, "PictureName", "ship-logo.gif");

    //Change the image position
    desg.set(handle, "X",   2.24f);

    //Change the image width
    desg.set(handle, "Width", 4.76f);
    desg.exit();

By creating a Designer instance in your Java program, you can modify an existing report or create a report (based on the existing catalog and query) with the methods provided by Designer API.

### JReport Engine Bean

`import jet.bean.*;
import java.awt.*;
import java.awt.event.*;`

Then, we will create an instance. To report with JReport Engine Bean, you should create an instance of it first. The constructor of JReport Engine Bean has no parameter. After the object is created, set the report home, report file, catalog file, result file (if necessary), parameter values (if necessary). After runReport(), call the export or print methods for exporting report result file to multiple output.

    bean = new JREngine();
    bean.setReportHome("C:\\JReport\\Designer");
    bean.setReportName("C:\\JReport\\Designer\\Demo\\Reports\\SampleReports\\CustomerAnalysis.cls");
    bean.setCatName("C:\\JReport\\Designer\\Demo\\Reports\\SampleReports\\SampleReports.cat");
    bean.setTimeZone("CST");
    bean.setParamValues("p_StartDate=01/01/2006,p_EndDate=12/31/2007");
    bean.setResultFile("c:\\jreport\\designer\\temp\\CustomerAnalysis.rst");
    bean.runReport();

    bean.exportToHtml("C:\\test\\CustomerAnalysis.html");
    bean.exportToPdf("C:\\test\\CustomerAnalysis.pdf");
    bean.printReport();

### JReport Result Viewer Bean

`import jet.bean.*;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;`

Then, we will create an instance. To run with JReport Result Viewer Bean, you should create an instance of it first. The constructor of JReport Result Viewer Bean has no parameter. After the object is created, set the report name, set temp path (if not set then the current path will be the default). After runReport(), call the export or print methods for exporting report result file to multiple output. The important thing is that the report name here is the report result generated by JReport Engine. In other words, the report result file is generated by JReport Designer, JReport Engine Bean or JReport Enterprise Server.

    bean = new JRResultViewer();
    bean.setShowInfoLevel(bean.vDebug | bean.vError);
    bean.setReportName("C:\\JReport\\Designer\\temp\\CustomerAnalysis.rst");
    bean.runReport("yes");

    bean.exportToPS("C:\\test\\CustomerAnalysis.ps");
    bean.exportToRtf("C:\\test\\CustomerAnalysis.rtf");
    bean.printReport();