getting started with jreport designer - jinfonet can specify jdbc drivers in two ways: • specify...

38
Getting Started with JReport Designer Contents INTRODUCTION............................................................................................................... 2 Overview and Layout............................................................................................. 2 FIRST STEPS.................................................................................................................. 3 Installing JReport Designer .................................................................................. 3 Troubleshooting Installation/Running Problems ............................................... 3 Reporting Installation/Running Problems ........................................................... 4 JREPORT DESIGNER BASICS.......................................................................................... 5 JREPORT DESIGNER FEATURES ..................................................................................... 8 Design Tools .......................................................................................................... 8 Data Access Tools ............................................................................................... 16 Reporting Features .............................................................................................. 16 Report Delivery Features .................................................................................... 17 Tools for Programmatical Report Design.......................................................... 18 JREPORT DESIGNER QUICK TOUR................................................................................ 20 Designing a Report with Report Wizard ............................................................ 20 Testing Your Report ............................................................................................ 27 Designing, Running, and Viewing a Report Programmatically ....................... 28 Delivering Reports ............................................................................................... 30 Remote Access of JReport Enterprise Server .................................................. 32 Demo Reports ...................................................................................................... 36

Upload: ngoduong

Post on 09-Mar-2018

220 views

Category:

Documents


3 download

TRANSCRIPT

Page 1: Getting Started with JReport Designer - Jinfonet can specify JDBC drivers in two ways: • Specify the JDBC driver's Java class name in the Connect dialog box. • Edit c:\JReport\bin\jdbcdrivers.properties,

Getting Started with JReport Designer Contents

INTRODUCTION...............................................................................................................2

Overview and Layout.............................................................................................2 FIRST STEPS..................................................................................................................3

Installing JReport Designer ..................................................................................3 Troubleshooting Installation/Running Problems ...............................................3 Reporting Installation/Running Problems...........................................................4

JREPORT DESIGNER BASICS..........................................................................................5 JREPORT DESIGNER FEATURES .....................................................................................8

Design Tools ..........................................................................................................8 Data Access Tools...............................................................................................16 Reporting Features..............................................................................................16 Report Delivery Features ....................................................................................17 Tools for Programmatical Report Design..........................................................18

JREPORT DESIGNER QUICK TOUR................................................................................20 Designing a Report with Report Wizard ............................................................20 Testing Your Report ............................................................................................27 Designing, Running, and Viewing a Report Programmatically .......................28 Delivering Reports...............................................................................................30 Remote Access of JReport Enterprise Server ..................................................32 Demo Reports ......................................................................................................36

Page 2: Getting Started with JReport Designer - Jinfonet can specify JDBC drivers in two ways: • Specify the JDBC driver's Java class name in the Connect dialog box. • Edit c:\JReport\bin\jdbcdrivers.properties,

Introduction Overview and Layout

Getting Started provides an introduction to JReport Designer. This section covers issues associated with installation, setup, configuration, and basic operation of JReport Designer. Getting Started also provides references to relevant topics in the User's Guide and User Reference sections. Getting Started is divided into the following sections:

First Steps: This section offers general installation and configuration information as well as how to troubleshoot and report installation and running problems.

JReport Designer Basics: This section lists tasks and commands available in JReport Designer.

JReport Designer Features: This section offers a high-level overview of JReport Designer's major features, so that you can evaluate whether JReport is the right tool for you at this time.

JReport Designer Quick Tour: This section provides a guided tour of JReport Designer reporting solutions and shows how to use the GUI and the programming tools to design, test, deliver, and deploy reports. Both standalone and client/server scenarios are discussed.

2

Page 3: Getting Started with JReport Designer - Jinfonet can specify JDBC drivers in two ways: • Specify the JDBC driver's Java class name in the Connect dialog box. • Edit c:\JReport\bin\jdbcdrivers.properties,

First Steps Installing JReport Designer

JReport Designer can be downloaded for evaluation from our web site. The full-featured product download can be used for 30 days free of charge. An installation wizard is provided to guide you through the installation process.

1. To download the installation file, go to our download center at http://www.jinfonet.com/webpage/support/download.htm.

2. To install JReport Designer, you first need to register in order to obtain the evaluation key. The registration form is located at http://www.jinfonet.com/JReportRegister.htm.

3. To run JReport Designer, start JReport Designer with the batch file %installroot%\bin\JReport.bat.

Troubleshooting Installation/Running Problems

If you have trouble installing and running JReport Designer or encounter any problems during reporting, you can use the following steps to troubleshoot the problem first.

1. Check whether you meet basic system requirements for installation. See the JReport Designer User’s Guide/Installing and Launching JReport Designer. NOTE: We offer JReport Designer for Windows 9x/2000/NT versions. (JReport Designer does not come in a special installation package for other platforms.) To install JReport Designer, you can run the extracted class file (generated in Windows) and do a manual installation. We also provide JReport Designer installation instructions on Macintosh. We do not normally recommend this option. We recommend rather that you launch JReport Designer on a Windows OS to do the report design work. You can then deploy reports to JReport Enterprise Server for which we have a Windows version and a Unix version (Solaris, Linux, HP-Unix, AIX); the reports can be run in the server/client environment.

2. Configure JDBC drivers. JReport Designer supports: • Database connections via various JDBC

drivers, and • ODBC data sources via Sun's JDBC-ODBC

bridge. NOTE: You need to install the JDBC or ODBC driver before installing JReport Designer Edition. For more information on how to install the driver, please refer to the appropriate JDBC or ODBC manuals.

3

Page 4: Getting Started with JReport Designer - Jinfonet can specify JDBC drivers in two ways: • Specify the JDBC driver's Java class name in the Connect dialog box. • Edit c:\JReport\bin\jdbcdrivers.properties,

You can specify JDBC drivers in two ways:

• Specify the JDBC driver's Java class name in the Connect dialog box.

• Edit c:\JReport\bin\jdbcdrivers.properties, in which one or more JDBC drivers can be specified: jdbc.drivers=foo.bah.Driver:wombat.sql.Driver

3. Please refer to www.jinfonet.com/hotfixes/Faq.htm for frequently asked questions and their solutions.

Reporting Installation/Running Problems

If your installation/running problem persists, despite troubleshooting, please report it to Jinfonet Support ([email protected]) with the following information:

1. Please describe the precise steps leading to the problem. 2. Run the batch file called "jrenv.bat" under the

%installroot%\bin subdirectory. Running this batch file will generate a file called "report.env" in the current directory. Send this file to us.

3. Send us the catalog file (*.cat and *.fml) and the report file (*.cls) with which you are having problems.

4. Please start JReport with the batch file DJReport.bat. Running this batch file will generate the log file JReport.log in the current directory. Try to reproduce the problem, and send this log file to us.

5. In order to resolve the technical issues you have reported, we need to access your report data so that we can re-create and analyze the problem. Regardless of the size of your database, we only require access to the data returned by the query of the particular report affected. We will be happy to execute a confidentiality agreement with you if necessary.

6. To extract the report data, in Catalog Browser, right click on the query that your report is using, and select the menu item “Create Cached Query Result.” Input the data file name and click the Save button. The query result will be saved in the file. Send us all the resulting files (<file name>.*, including the description file). If the main report contains subreport(s), repeat this step for each subreport.

4

Page 5: Getting Started with JReport Designer - Jinfonet can specify JDBC drivers in two ways: • Specify the JDBC driver's Java class name in the Connect dialog box. • Edit c:\JReport\bin\jdbcdrivers.properties,

JReport Designer Basics This section lists common tasks and operations available in different areas of JReport Designer. Each task or topic is covered in the User's Guide with detailed instructions and additional links/references as needed. For a brief overview on client-side designing of reports using JReport Designer, see the JReport Suite Documentation Overview/How the JReport Suite Works.

Configuration and Customization DataSource set-up Supplement the necessary classpath option for any external .class files in the batch file

Setting up a Connection Create a new catalog Set up a connection to connect with the data source Import SQL file Directly import user data source to the catalog EJB, XML data sources with the ModelWizard

Working on a Catalog Create/modify a query or UDS Create/modify any objects like a parameter, a formula, a summary etc. Create/modify any customized objects like a subreport, a chart, line, print date etc. Copy and paste functions on a formula and a query Report management and data management Save a catalog Save as a catalog Deploy a report locally or to JReport Enterprise Server with the Deploy Wizard

Report Development and Editing Create a new report with the Report Wizard Choose from various report templates User-defined template Vertical/horizontal page break Grouping, sorting, sum Parameters, formulas, DB-fields RTF text object Crosstab report, subreport, embedded subreport Chart/graph, drill-down on summary

Reporting Properties True type font Condition format (formula control of formatting) Dynamic group/sort Report Deploy Wizard National Language Support Maximum records for display Compressed report result file Style Saving

5

Page 6: Getting Started with JReport Designer - Jinfonet can specify JDBC drivers in two ways: • Specify the JDBC driver's Java class name in the Connect dialog box. • Edit c:\JReport\bin\jdbcdrivers.properties,

Underlay Suppressed, invisible, suppress blank section Wordwrap, autofit On new page, fill whole page NOTE: Different objects have different reporting properties. Detailed information for each object can be found in the User Reference.

Report View and Printing Paper, orientation, margins Table of contents Dynamic sort Zoom in/out Printing

Extensibility and APIs UDO: User-Defined Object and tool - the UDO Maker UDF: User-Defined Functions UDS: User Data Source Exit methods JReport Designer API - Design a report programmatically JReport Catalog API - Create and modify a catalog programmatically JReport Engine Bean - Run report within user applications JReport Result Viewer Bean - View the report result generated by JREngine within user applications JReport Catalog Bean - Manipulate and access the catalog of JReport

Product Integration Intergration with other web servers: WebLogic, SilverStream, WebSphere, Apache, Java Web Server, IIS, Netscape Application Server (for JReport Enterprise Server) WebSphere Business Components (SanFrancisco) JBuilder 3 Forte for Java Visual Age Visual Café ISV Integration - Novell

Exporting Information Report result file Email notification Report via email attachments Applet HTML PDF XLS RTF Postscript Plain text X character separator formats

6

Page 7: Getting Started with JReport Designer - Jinfonet can specify JDBC drivers in two ways: • Specify the JDBC driver's Java class name in the Connect dialog box. • Edit c:\JReport\bin\jdbcdrivers.properties,

CSV TSV XML

7

Page 8: Getting Started with JReport Designer - Jinfonet can specify JDBC drivers in two ways: • Specify the JDBC driver's Java class name in the Connect dialog box. • Edit c:\JReport\bin\jdbcdrivers.properties,

JReport Designer Features This section presents a run-down of JReport Designer's top features and provides basic information about each one. This is intended as a high-level overview. More detailed information with how-to steps on how to use each feature is provided in the User's Guide. If you browse the Table of Contents of the JReport Designer User's Guide, you can easily find the feature you need. A basic overview is presented here to aid in helping you understand and more speedily use JReport Designer in your own system.

Design Tools

Intuitive Main Working Environment The JReport Designer main window provides an intuitive and friendly design environment, supporting a point-and-click, drag-and-drop WYSIWYG interface.

You can select options from the Main Menu or click the buttons on the toolbars to perform actions. In addition, a variety of formatting commands are provided, ranging from changing color background or foreground to saving object styles, which can make your report more informative and visually appealing. The Runtime Viewer provides drill-down capabilities for reports that allow end-users to interactively explore associated data.

8

Page 9: Getting Started with JReport Designer - Jinfonet can specify JDBC drivers in two ways: • Specify the JDBC driver's Java class name in the Connect dialog box. • Edit c:\JReport\bin\jdbcdrivers.properties,

Catalog Browser All resources (such as data source connections, tables, queries, formulas, etc.) a report uses are saved as a catalog file (.cat). You can define the catalog using the Catalog Browser. All available resources are organized for ease of use on tabs and trees.

9

Page 10: Getting Started with JReport Designer - Jinfonet can specify JDBC drivers in two ways: • Specify the JDBC driver's Java class name in the Connect dialog box. • Edit c:\JReport\bin\jdbcdrivers.properties,

Report Inspector Properties and values of all objects in a report are displayed in a property sheet for you to view and change. Properties for different objects in the Report Inspector are displayed dynamically.

Commonly used properties for an object include: Underlay, link Suppressed, invisible, suppress blank section Wordwrap, autofit On new page, fill whole page PatternStyle FontFace, FontSize, Underline, Bold, Strikeout, Alignment Border width, borderline Many properties can be controlled dynamically by a formula.

10

Page 11: Getting Started with JReport Designer - Jinfonet can specify JDBC drivers in two ways: • Specify the JDBC driver's Java class name in the Connect dialog box. • Edit c:\JReport\bin\jdbcdrivers.properties,

Report Wizard The Report Wizard takes you step by step through the report-building process. Interactive tools for typical report construction are provided, including tables, labels, statements, crosstabs, form letters, and graphs. Reports can also be created from scratch by dragging & dropping report objects.

11

Page 12: Getting Started with JReport Designer - Jinfonet can specify JDBC drivers in two ways: • Specify the JDBC driver's Java class name in the Connect dialog box. • Edit c:\JReport\bin\jdbcdrivers.properties,

Query Editor The Query Editor allows you to easily join tables and set conditions through point-and-click and drag-and-drop actions.

Report Manager You can categorize reports easily using Report Manager.

12

Page 13: Getting Started with JReport Designer - Jinfonet can specify JDBC drivers in two ways: • Specify the JDBC driver's Java class name in the Connect dialog box. • Edit c:\JReport\bin\jdbcdrivers.properties,

Data Manager The Data Manager controls data retrieval, including factors such as the number of rows to be displayed and the duration for retrieval. The Data Manager can also store access information obtained in previous runs of each query.

Template and User-Defined Template

A template provides a basic format for a particular kind of report file. JReport Designer can translate and expand a template to build a complete report file. You can also build different reports based on the same data by using various templates. You can choose the templates supplied by JReport Designer or design templates as you need. Templates provided include: invoice, crosstab, subreport, HBlank (horizontal page break), standard, and drop table.

13

Page 14: Getting Started with JReport Designer - Jinfonet can specify JDBC drivers in two ways: • Specify the JDBC driver's Java class name in the Connect dialog box. • Edit c:\JReport\bin\jdbcdrivers.properties,

Catalog Doctor--Problem Diagnosis Tool Catalog Doctor is a tool provided to help you maintain the validity of the resources in your catalog. For example, when you delete a column in your database, you need to update all tables, formulas, and queries which referenced this column, so that the report can be run correctly. Catalog Doctor helps you update resources as needed. To run Catalog Doctor, launch the batch file %installroot%\bin\CatDr.bat.

Catalog-Resources Repository The JReport Designer catalog file contains object definitions that are used by reports in the catalog. Components available for building your report, including data sources, queries, formulas, parameters, and various data and drawing objects, are available for you to pick and drop into your report. All of the resources can be shared among reports. Some important objects and their usage are reviewed below: Parameter: A variable whose value is an input value at run time. It plays an important role in dynamic control reporting at runtime to filter records, display text on the fly, etc. Formula and Summary: Objects to be computed at run time, which allow you to manipulate field data by performing calculations on data, controlling what data is displayed, and even creating new data not directly available from a database. Summary is essentially a special formula. Customized Object: These objects can be customized with their own properties like color, length, etc., before being inserted into a report. Drawing objects: line, box, round box, arc, oval, label, image.

14

Page 15: Getting Started with JReport Designer - Jinfonet can specify JDBC drivers in two ways: • Specify the JDBC driver's Java class name in the Connect dialog box. • Edit c:\JReport\bin\jdbcdrivers.properties,

Special fields: user name, print date, print time, fetch time, modified data, modified time, record number, group name, group number, total group number, page number, total page number, SQL statement.

15

Page 16: Getting Started with JReport Designer - Jinfonet can specify JDBC drivers in two ways: • Specify the JDBC driver's Java class name in the Connect dialog box. • Edit c:\JReport\bin\jdbcdrivers.properties,

Data Access Tools

Flexible Connection to Data Sources A Connection is a listing of the database objects accessible through JDBC or JDBC-ODBC Bridge. If you want to use tables, views, stored procedures and other objects stored in a database, you need to add the objects into a Connection in the Catalog Browser. You can also create imported queries from an existing SQL file. In addition, JReport Designer can access data from the user's application through a Data Source Driver. The Data Source Driver described in this document is designed to extend JReport Designer 's capability of accessing data. Using the Data Source Driver, users can produce reports by providing data from user's programs or any external sources. The Data Source Driver is a Java class that provides the data set to JReport Designer when the report is generated at runtime. Normally, the report engine obtains the report data set from JDBC calls with SQL statements. When the report uses the Data Source Driver, the report engine gets the data set from the Data Source Driver. In other words, the Data Source Driver is an alternative to the JDBC calls. In a word, JReport Designer is open to data. The JReport Designer Engine supports multiple data source types: XML, EJB, JDBC/ODBC (including commonly used databases like Access, Oracle, Sybase, SQL Server, Informix, IBM DB/2 and more), plain text, or any user data source. For JDBC/ODBC, we also support stored procedure and SQL file input.

Reporting Features

Nested Dynamic Group/Sort You can make a multi-level nested group/sort report by selecting fields as grouping/sorting criteria with the Group/Sort Wizard. In addition, you can define the group/sort criteria in run time, that is to say, you can use Dynamic group/sort.

Multiple Sub-Reports and Sections JReport products allow you to insert sub-reports and sections at any time.

Conditional Formatting You can flag field values, suppress fields, and perform other actions on fields that meet certain conditions by formatting the field conditionally. This is done by setting a property value to be controlled by a DBField or a formula field, rather than a constant value.

3D Graphs and Charts You can insert charts and graphs into any report using the Charts/Graphs Wizard.

Cross-Tabs A Cross Tab is an object that summarizes data and presents the summaries in a compact row and column format. This allows comparisons and identification of trends to be displayed. You can insert the Cross-Tab object using the Cross-Tab Wizard.

RTF Text

16

Page 17: Getting Started with JReport Designer - Jinfonet can specify JDBC drivers in two ways: • Specify the JDBC driver's Java class name in the Connect dialog box. • Edit c:\JReport\bin\jdbcdrivers.properties,

Text Object supports basic rtf properties, such as font color, size, picture, paragraph alignment, etc. You can also insert database fields, formula fields, and parameter fields into text objects.

Drill-down Analysis You can drill down on Aggregate level fields, a component of chart objects provided for analysis.

Hyperlinks You can use Hyperlink UDO objects to create hyperlinks.

Image File Input Images (.bmp, .gif, .jpg) can be directly inserted into a report or layered underneath as background. We also support images stored in a database as we would any common database field (termed DB-Field).

UDF - User Defined Formula Functions JReport Designer provides a number of built-in formula functions for users. However, if these functions do not satisfy your needs, you can design your own formula functions according to your requirements. We provide user-defined formula functions to implement your formulas.

UDO - User Defined Object User Defined Objects extend JReport Designer with new object types. A user defined object (UDO) is an object inherited from the JReport Designer system’s object. You can add and modify new properties, as well as use other existing methods. You can then specify new methods for modifying the properties of your UDO. The UDO can be inserted into JReport Designer as if it is a regular JReport Designer Object. Thus, the UDO becomes a part of the report created by JReport Designer.

Exit Method - Call Back Method During Report Running Process JReport Designer has developed three Exit functions for users: BeforeRun, AfterRun, and AfterInitParameter. These functions enable you to develop an action of your own to be called before, after, or during the process of running the report.

National Language Support A report file can be deployed to JReport Enterprise Server for running in the client/server scenario, where different clients can select different languages for the corresponding rendering of the report (using language-dependent text with the Label object).

Page Level Security Beginning with Version 4.0, JReport Designer supports page level security, which offers a security mechanism for controlling access to the report. After a report is deployed to the JReport Enterprise Server, different users can view different groups based on their access privileges.

Report Delivery Features

Pipeline Output Stream To optimize performance, JReport Designer views report pages before they are completely generated.

17

Page 18: Getting Started with JReport Designer - Jinfonet can specify JDBC drivers in two ways: • Specify the JDBC driver's Java class name in the Connect dialog box. • Edit c:\JReport\bin\jdbcdrivers.properties,

Multiple Export JReport products can generate result files in many different formats. For example, a Report Result file can be viewed with JReport viewer, PDF, HTML, XML, RTF, APPLET, Excel, and Standard Data Format (CSV, TSV).

E-mail Report Delivery You can send an email notice when JREngine runs out a report. Report results or various outputs can be attached with the email and sent directly to specified addresses.

Deploying Catalog and Report Source File You can deploy your catalog files and report files to another location on your local drive or to JReport Enterprise Server for running in the server/client mode.

Tools for Programmatical Report Design

JReport Designer provides developers the option to develop complete reports visually. The designer in JReport Designer provides a user-friendly GUI to allow easy design of reports. The View tab, when clicked, prompts the JREngine to run the report. The report result is then displayed in the viewer. This visual designing tool drastically increases productivity by allowing users to design a complete report right inside the visual environment. However, the programmatic approach is also provided for in JReport Designer. Both approaches can be integrated and complement each other.

JReport Designer API Almost all the design work you need to do can be achieved within your application. The methodology of editing and refining a report with the Designer API is identical to that employed in JReport Designer. Using Designer API, you can edit the layout of a report by changing property values, or modify the report by inserting objects such as DBfield, formula, text object, chart, etc.. Based on an existing catalog and query, you can create and design a report with Designer API. Our IDEs include JBuilder, SilverStream, Visual Age, Visual Café, Forte, and more.

JReport Catalog API Catalog API allows you to utilize programming to manipulate a catalog. You can create or edit a catalog with the methods provided by Catalog API instead of working in the GUI design mode in JReport Designer. The combination of Catalog API and Designer API provides you with a Java development environment that enables you to create any report to meet your needs.

JReport Engine Bean To use JReport Engine Bean, you first use JReport Designer to build a report/template, then save the report file as a .cls file. You can then call JReport Engine Bean in your own application to generate report results, and export the results to other formats like PDF, Text, HTML, and Rst, or to a printer for printing. With the robust JReport Engine, you can set runtime options to run the report result. You can set the output format, parameter values, even a new connection to access a different database with the exact same table structure.

18

Page 19: Getting Started with JReport Designer - Jinfonet can specify JDBC drivers in two ways: • Specify the JDBC driver's Java class name in the Connect dialog box. • Edit c:\JReport\bin\jdbcdrivers.properties,

JReport Result Viewer Bean The report result (physical file or the report result set) can be viewed locally through JReport Result Viewer. The viewer can also export the result to other formats: PDF, Text, HTML, and Rst, or to a printer for printing.

JReport Catalog Bean JReport Catalog Bean provides a programming API to manipulate and access the catalog of JReport Designer. The catalog is used to hold all the resources that are used to build a report in JReport Designer. JReport Catalog Bean enables the user to:

Create an empty catalog. Add objects to a catalog. Remove objects from a catalog.

19

Page 20: Getting Started with JReport Designer - Jinfonet can specify JDBC drivers in two ways: • Specify the JDBC driver's Java class name in the Connect dialog box. • Edit c:\JReport\bin\jdbcdrivers.properties,

JReport Designer Quick Tour This section offers a quick tour of JReport Designer and demonstrates how to design, test, deliver, and deploy reports either using the visual interface or programming tools JReport Designer provides. For detailed information on how JReport Designer works, please refer to the Tutorial and User’s Guide.

Designing a Report with Report Wizard

This subsection explains how to create a quick report using the Report Wizard. Steps are briefly detailed below. For more information, please refer to the User's Guide/Developing Reports with Report Wizard.

1. After installing, start JReport Designer with the batch file %installroot%\bin\JReport.bat.

2. Choose a template, such as Standard on the New tab in the Open Report dialog.

20

Page 21: Getting Started with JReport Designer - Jinfonet can specify JDBC drivers in two ways: • Specify the JDBC driver's Java class name in the Connect dialog box. • Edit c:\JReport\bin\jdbcdrivers.properties,

3. Preview the overall format of the template you selected by pressing the Show Template.. button to display the template.

4. If satisfied with the template, go through Report Wizard as sequenced below to create a report step by step.

21

Page 22: Getting Started with JReport Designer - Jinfonet can specify JDBC drivers in two ways: • Specify the JDBC driver's Java class name in the Connect dialog box. • Edit c:\JReport\bin\jdbcdrivers.properties,

5. Data - Select the data source from all data objects to form a Working Set.

6. Joins - Join multiple tables in the default or the manual way.

22

Page 23: Getting Started with JReport Designer - Jinfonet can specify JDBC drivers in two ways: • Specify the JDBC driver's Java class name in the Connect dialog box. • Edit c:\JReport\bin\jdbcdrivers.properties,

7. Conditions - Specify the criteria which will be used to retrieve data from the database to form the query of the report.

8. Display - Select which fields to show in the report.

23

Page 24: Getting Started with JReport Designer - Jinfonet can specify JDBC drivers in two ways: • Specify the JDBC driver's Java class name in the Connect dialog box. • Edit c:\JReport\bin\jdbcdrivers.properties,

9. Group - Enter the criteria to define multi-level groups, and specify the ordering of the groups.

10. Sort - Sort records within the groups and select the sorting fields.

24

Page 25: Getting Started with JReport Designer - Jinfonet can specify JDBC drivers in two ways: • Specify the JDBC driver's Java class name in the Connect dialog box. • Edit c:\JReport\bin\jdbcdrivers.properties,

11. Summary - Specify summary functions.

12. Other - Preview your selection so far in Report Wizard and make any adjustments you need to make.

25

Page 26: Getting Started with JReport Designer - Jinfonet can specify JDBC drivers in two ways: • Specify the JDBC driver's Java class name in the Connect dialog box. • Edit c:\JReport\bin\jdbcdrivers.properties,

13. Style - Choose the layout and style in which you want your data to be displayed.

14. Click on Finish to complete your report. At this point, after going through Report Wizard, you will get a draft report. You can refine the report further with Report Inspector. Please refer to the User's Guide/Refining the Report Layout for more information.

26

Page 27: Getting Started with JReport Designer - Jinfonet can specify JDBC drivers in two ways: • Specify the JDBC driver's Java class name in the Connect dialog box. • Edit c:\JReport\bin\jdbcdrivers.properties,

15. Save your report design.

Testing Your Report

1. Click the View tab as displayed in the report window below to test the report result you have just created.

27

Page 28: Getting Started with JReport Designer - Jinfonet can specify JDBC drivers in two ways: • Specify the JDBC driver's Java class name in the Connect dialog box. • Edit c:\JReport\bin\jdbcdrivers.properties,

2. Click the View tab. You will see a result as shown partially below.

Designing, Running, and Viewing a Report Programmatically

Recall that you have just designed a report with the designer, and saved the report file as a .cls file. When you run the report within JReport Designer, the JReport engine will connect with the data source to fetch the data, so that you can view the report result in the viewer. The above three processes can also be achieved, as defined below, within your application. For programming purposes, we provide JReport Designer API, JReport Engine Bean, and JReport Result Viewer Bean.

JReport Designer API 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. import java.io.*; import java.awt.*; import jet.api.*; import jet.jetc.*; import jet.universe.exception.*;desg = new Designer(path, cat); desg.setLog(new FileOutputStream(log), "8859_1");

28

Page 29: Getting Started with JReport Designer - Jinfonet can specify JDBC drivers in two ways: • Specify the JDBC driver's Java class name in the Connect dialog box. • Edit c:\JReport\bin\jdbcdrivers.properties,

//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 "sky.gif" desg.set(handle, "PictureName", "sky.gif"); // change the image position desg.set(handle, "X", 2.24f); // change the image width desg.set(handle, "Width", 4.76f); desg.exit();

JReport Engine Bean To report with JREngine Bean, you should create an instance of JREngine Bean first.import jet.bean.*; import java.awt.*; import java.awt.event.*; Then you need to create an instance. The constructor of JREngine Bean has no parameters. After the object is created, you should 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 the report result file to multiple output. bean = new JREngine(); bean.setReportHome("c:\\JReport"); bean.setReportName("c:\\JReport\\demo\\reports\\phaseorder.cls"); bean.setCatName("c:\\JReport\\demo\\reports\\Tutorial.cat"); bean.setParamValues("STARTDATE=1998-05-15,ENDDATE=1998-06-10"); bean.setResultFile("c:\\JReport\\temp\\phaseorder.rst"); bean.runReport(); bean.exportToHtml("c:\\test\\phaseorder.html"); bean.exportToPdf("c:\\test\\phaseorder.pdf"); bean.printReport();

JReport Result Viewer Bean To run your report with JRResultViewer Bean, you should create an instance of JRResultViewer Bean first. import jet.bean.*; import java.awt.*; import java.awt.event.*; import javax.swing.*; Then you need to create an instance. The constructor of JRResultViewer Bean has no parameters. After the object is created, you should set the report name, set temp path (if not set, the current path will be the default). After runReport(), call the export or print methods for exporting the report result file to multiple output.

29

Page 30: Getting Started with JReport Designer - Jinfonet can specify JDBC drivers in two ways: • Specify the JDBC driver's Java class name in the Connect dialog box. • Edit c:\JReport\bin\jdbcdrivers.properties,

The important thing here is that the report name 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\\temp\\phaseorder.rst"); bean.runReport("yes"); bean.exportPS("c:\\test\\phaseorder.ps"); bean.exportToRtf("c:\\test\\phaseorder.rtf"); bean.printReport();

Delivering Reports

Export Report Result to HTML JReport Designer can export a report to various formats: JReport Result, Text, HTML, PDF, Postscript File, Mail, Applet, Excel File and Fax. To export the report, use the menu option File/Export. The steps below illustrate how to export a report to HTML.

1. First, select File/Export/To HTML to bring up the Web Wizard dialog.

2. Report Tab – Type in the HTML file name and decide

whether you would like to export to a Multiple or Single file. You can also specify other details, such as the browser and table format, etc.

30

Page 31: Getting Started with JReport Designer - Jinfonet can specify JDBC drivers in two ways: • Specify the JDBC driver's Java class name in the Connect dialog box. • Edit c:\JReport\bin\jdbcdrivers.properties,

3. Directory Tab - Specify the directory in which to place the exported HTML files.

4. ChartApplet Tab - Choose whether to display charts. 5. Note Tab – Provide any other relevant information for the

HTML page. 6. View the result as shown below.

Note: We selected Multifile in this example. JReport Designer designates a serial number for each HTML page. This means that if you have a 3-page report named "invoice," JReport Designer will create three files called invoice_1.html, invoice_2.html and invoice_3.html. You can go to the next or previous page by clicking the Next or Previous buttons.

Deploying a Report JReport Designer, including all the shipped components (like JReport Designer API, JReport Engine Bean, JReport Result Viewer Bean), is the client side report development environment. Pre-developed reports can also be deployed to other places or to JReport Enterprise Server for running in the server/client scenario. For detailed information on deploying reports from JReport Designer, please refer to User's Guide/Deploying Resources From JReport Designer.

31

Page 32: Getting Started with JReport Designer - Jinfonet can specify JDBC drivers in two ways: • Specify the JDBC driver's Java class name in the Connect dialog box. • Edit c:\JReport\bin\jdbcdrivers.properties,

Remote Access of JReport Enterprise Server

Using a Browser 1. First, you need to load a Web Browser (here we use IE),

bar. After

then type in the home page of the server in the address

2. Login, you can view the directories on the server, and select the directory containing the catalog and the specific report you wish to view.

32

Page 33: Getting Started with JReport Designer - Jinfonet can specify JDBC drivers in two ways: • Specify the JDBC driver's Java class name in the Connect dialog box. • Edit c:\JReport\bin\jdbcdrivers.properties,

3. For our example, we have chosen tutorial.cat which is

under /AccessDemo.

4. Select one report. Click Advanced Run in the Control

column.

33

Page 34: Getting Started with JReport Designer - Jinfonet can specify JDBC drivers in two ways: • Specify the JDBC driver's Java class name in the Connect dialog box. • Edit c:\JReport\bin\jdbcdrivers.properties,

5. Select the output format and click the Submit button.

34

Page 35: Getting Started with JReport Designer - Jinfonet can specify JDBC drivers in two ways: • Specify the JDBC driver's Java class name in the Connect dialog box. • Edit c:\JReport\bin\jdbcdrivers.properties,

6. The following report result is displayed.

Client Viewer Bean

To use the Client Viewer Bean, the first thing you need to do is to download the JREntVBean.zip file from the Jinfonet web site. The file JREntVBean.zip should be used when compiling and running your application program which calls JReport Viewer Bean. Inside the JREntVBean.zip file, you will find a document named ViewerBeanUsage.htm which introduces the files in JREntVBean.zip. There are three methods to invoke JReport Viewer Bean, depending on how much control your application requires: One Step Viewer In this method, your Java applications will call the JReport bean named JRDirectViewer and provide the following properties: setServerName ("theServerName"); setPort ("thePortNumber"); setReportName ("theReportName"); setCatName ("theCatalogName"); setLoadReport ("Yes/No"); After the JRDirectViewer bean is loaded, it will ask JReport Enterprise Server to run the report and pop up a dialog on the screen to ask you to input the report parameters (if needed).

35

Page 36: Getting Started with JReport Designer - Jinfonet can specify JDBC drivers in two ways: • Specify the JDBC driver's Java class name in the Connect dialog box. • Edit c:\JReport\bin\jdbcdrivers.properties,

Two Step Viewer In this method, your Java application first calls a JReport bean named JRPrepareViewer to prepare the parameters with the following properties: setServerName ("theServerName") setPort ("thePortNumber") setReportName ("theReportName") setCatName ("theCatalogName") setLoadReport ("Yes/No") After the parameters are prepared, the second JReport bean named JRRunViewer will be called to provide the parameter with the following properties: setServerName ("theServerName") setPort ("thePortNumber") setReportName ("theReportName") setCatName ("theCatalogName") setLoadReport ("Yes/No") setParameters ("Parameters") Second Step Viewer This method is identical to the second step of the Two Step method. Your application has already known the parameters, (meaning the parameters are prepared), so it calls the JReport bean named JRRunViewer directly in one step with the required properties: setServerName ("theServerName") setPort ("thePortNumber") setReportName ("theReportName") setCatName ("theCatalogName") setLoadReport ("Yes/No") setParameters ("Parameters")

Demo Reports

JReport Designer provides you with some typical demo reports available under %installroot%demo\reports\tutorial.cat. Below is a listing and brief introduction of the demo reports. 3DArrayBarChart.cls Demonstrates a chart type: 3D bar, and with table. 3DPieChart.cls Demonstrates a chart type: 3D pie, and with table. BarChart.cls Demonstrates a chart type: 3D bar. BarLineChart.cls Demonstrates a chart type: Combo (Bar_Line), and with table. Bubble.cls Demonstrates a chart type: Bubble, and with table.

36

Page 37: Getting Started with JReport Designer - Jinfonet can specify JDBC drivers in two ways: • Specify the JDBC driver's Java class name in the Connect dialog box. • Edit c:\JReport\bin\jdbcdrivers.properties,

ConditionalControlByFormula.cls Demonstrates the conditional control by a formula. Crosstab.cls A report on regional sales. Shows the usage of Cross-tab. CustomersAddress.cls Lists customer address information with text object. DateParameterUsage.cls Reports customer order information. Parameters are used to list data only for some specified days. DynamicQuery.cls Shows the usage of dynamic query. ExistingQueryUsage.cls A report on product information created by a query file. FormLetter.cls A sample form letter that helps you create a pre-defined letter more easily. FormulaUsage.cls Created with multiple tables. Shows the usage of formula and summary. GroupByDate.cls A report which reports order information per week and per month. Demonstrates the usage of a group by a field related to date. GroupingWithFormulas.cls Lists customer information by alphabetical order. Demonstrates how to group with a formula. ImageUsage.cls A demo report of an order list. Shows how to use image and drawing objects, and how to set property values such as color. Invoice.cls A demo report of a typical invoice. LineChart.cls Demonstrates a chart type: 3D line. ListByCategory.cls Demonstrates how to use a sub-report to create a complex report. Four sub-reports are used in this report: SbyRegion-Sub1.cls, SbyRegion-Sub2.cls, Crosstab.cls, and BarChart.cls. OrderForm.cls A demo report of a typical order form. PageHeaderSuppression.cls Demonstrates how to suppress a certain section on the first page.

37

Page 38: Getting Started with JReport Designer - Jinfonet can specify JDBC drivers in two ways: • Specify the JDBC driver's Java class name in the Connect dialog box. • Edit c:\JReport\bin\jdbcdrivers.properties,

ParameterUsage.cls Reports customer order information. A parameter is used to list data only for some specified regions. Radar.cls Demonstrates a chart type: Radar, with table. RunningTotalFormula.cls A report of annual sales which calculates the annual sales for each page. Shows the usage of a running total. SbyRegion-Sub1.cls A sub-report of the report ListByCategory.cls. SbyRegion-Sub2.cls A sub-report of the report ListByCategory.cls. SortByColumn.cls A sub-report for SubreportOfMainReport.cls SQLUsage.cls A demo report created from a SQL file. StockChart.cls Demonstrates a chart type: Stock. SubreportOfMainReport.cls A report with a sub-report object listing all employees with salaries lower than the group average salary. SummaryData.cls A chart and graph demo report which creates graphical views of the summarized data. SummaryDataCrosstab.cls A cross tab demo report which summarizes data and presents summaries in a compact row and column format. TableFormatting.cls Shows how to set the color with formula. TableReport.cls Table report that uses style groups. TableWithGrouping.cls A report on customer sales created with a single table. TextObjectEmbedded.cls A demo report using letters. Shows how to use a text object.

38