Добавил:
Upload Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
Скачиваний:
81
Добавлен:
11.05.2015
Размер:
2.11 Mб
Скачать

Application Distribution

Although the Seagate Crystal Report Designer Component is similar to Seagate Crystal Reports, it is made up of a separate group of files. If you will be distributing your application, you need to familiarize yourself with the new runtime distribution library. Before releasing your Visual Basic applications, review the list of files in the Runtime File Requirements in online Help.

Installing the Report Designer Component

The Report Designer Component can be installed as part of the standard Seagate Crystal Reports installation process. The following sections describe installation steps specific to the Report Designer Component.

System Requirements

The Seagate Crystal Report Designer Component has the following system requirements:

¾Microsoft Windows 95, Windows 98, or Windows NT 4 (Server or Workstation)

¾Visual Basic versions 5.0 and 6.0 (Professional or Enterprise Edition)

¾Netscape Navigator or Microsoft Internet Explorer (Version 3.0 or higher)

¾x86 processor or higher

¾32 MB RAM (minimum)

¾22 MB hard drive space (minimum for a full installation)

¾CD-ROM drive

Installation

NOTE: The Seagate Crystal Report Designer Component is available with Microsoft Visual Basic 6.0 or as a download from the Seagate Software web site (www.seagatesoftware.com).

Using the Seagate Crystal Report Designer Component

This section is intended as a complete tutorial that introduces you to using the Report Designer Component in Visual Basic. First, you will add the Report Designer to a Visual Basic project. The tutorial then takes you through the steps of selecting data, designing a report through the Create Report Expert, and adding the Smart Viewer component to a Visual Basic form. Finally, you will run your application and display the report in the Smart Viewer.

Following the tutorial, you will examine the objects and the code that were added to your Visual Basic project. By understanding how a Report Designer project is created, you can leverage your knowledge of Visual Basic to customize and control how reports are displayed in your application.

NOTE: The instructions given here can be used in either version 5 or 6 of Visual Basic, except where specifically noted.

The Report Designer Component

151

The following topics are discussed in this section:

The tutorial that follows in Part One will take you through the basic steps of adding the Report Designer Component to a Visual Basic project, connecting to a database through ActiveX Data Objects, designing a report in the Create Report Expert, adding the Smart Viewer control to a form, and viewing the report at runtime. Most of this work is handled through visual interfaces and Experts designed to simplify the process. However, when you create your own applications, you will quickly find the need to work directly with the controls and objects that have been added to your project, discussed in Part Two.

Part One

Adding the Report Designer Component to a Project, Page 152

Selecting Data, Page 153

The Report Expert, Page 154

Adding the Smart Viewer, Page 155

Running the Application, Page 155

Part Two

CrystalReport1 - The Report Designer Component, Page 156

CRViewer1 - The Smart Viewer Control, Page 156

The Code, Page 157

Report Packages, Page 158

Adding the Report Designer Component to a Project

The Report Designer Component is an ActiveX Designer, and a reference to the component must be added to your project. Once a reference is made from Visual Basic, the Report Designer Component can be added directly to your project.

1With Visual Basic running, select New Project from the File menu. The New Project dialog box appears.

2Select the Standard EXE icon and click OK. Visual Basic creates a new project for you with a single form.

3From the Project menu, select the Components command. The Components dialog box is displayed.

4Click the Designers Tab in the Components dialog box to see a list of all available ActiveX Designers.

5Select the Crystal Reports 7.0 ActiveX designer. The check box for this component should be toggled on.

6Click OK when finished.

7From the Project menu, select the Add ActiveX Designer submenu, then select the Crystal Reports 7.0 command that appears. A new Report Designer component is added to your project, and the Report Gallery appears inside the Visual Basic IDE.

NOTE: In Visual Basic 6.0, the command Add Crystal Reports 7.0 will appear directly on the Project menu.

The Report Designer Component

152

Selecting Data

The first step to creating any report is selecting the source of the data that will be displayed. The Report Designer Component supports data sources exposed through Data Access Objects (DAO), Remote Data Objects (RDO), ActiveX Data Objects (ADO), Crystal Data Objects (CDO) through a Data Definition File, and Visual Basic Data Environments. If you have installed the full Seagate Crystal Reports product, you can also access any source of data supported by Seagate Crystal Reports, including SQL servers and ODBC data sources. In the following steps, you will connect to a data source using ADO.

1In the Report Gallery, click the Standard button to design a standard report using the Report Designer Component. The Create Report Expert appears with the Data Tab active.

NOTE: If you close the Report Gallery dialog box without selecting a report type, the Report Designer Component will assume that you wish to use an Empty Report. You will be prompted to add the Smart Viewer control to your project.

2In the Data Source section of the Data Tab, click the Project button to select a data source for your Visual Basic project. The Select Data Source dialog box appears.

NOTE: The VB Data Environment button on the Data Tab allows you to connect to an existing Visual Basic Data Environment. The Custom button allows you to connect to a data source other than RDO, ADO, DAO, or a Data Definition File. This option is only available if you have performed a complete install of Seagate Crystal Reports. For more information, refer to Working with data, Page 158.

3Verify that the first option in the dialog box, ODBC, is selected. This option allows you to connect to an ODBC data source through ADO or RDO.

4In the drop-down list below the ODBC option, select Xtreme sample data. This is a sample database and ODBC data source created when you installed Seagate Crystal Reports.

5Click the Advanced button. The Advanced Options dialog box appears.

6Make sure the ADO option is selected in the Advanced Options dialog box. You will connect to the Xtreme sample data data source through ActiveX Data Objects.

7Click OK in the Advanced Options dialog box, and notice that ADO appears in parentheses next to the ODBC option.

8Click Next in the Select Data Source dialog box. The Select Recordset dialog box appears. Now that you have specified a data source and a connection type (ADO), you must specify the data within the data source that will be used for the report.

9From the Object drop-down list, select Customer. This is the Customer table in the Xtreme database. Note that if you are familiar with the SQL query language, you could also use the SQL option and write a SELECT statement. The Build button next to the SQL option opens Microsoft Query so that you can visually build a SQL statement.

10Click Finish to return to the Create Report Expert. Notice that ado now appears in the Tables list of the Data Tab, indicating that you have selected an ActiveX Data Objects data source. You are now ready to design your report.

The Report Designer Component

153

The Report Expert

Once you’ve selected a data source, you can continue designing your report through the Report Expert. The Report Expert in the Report Designer Component works exactly like the Report Expert in the Report Designer for Seagate Crystal Reports.

1Select the Fields Tab in the Create Report Expert. The Database Fields list box lists the ADO connection that you made, and all available fields from the table you selected.

2Select Customer Name in the Database Fields list box, drag and drop the field into the Report Fields list box. ado.Customer Name will appear in the list box. You have just specified that data from the Customer Name field appear in your report.

3Continue using the drag and drop procedure, or use the Add button on the Fields Tab, to add the Last Year’s Sales, City, and Region fields to your report.

4Click the Sort Tab to sort the data in your report.

5Once again, use either the drag and drop method or the Add button to select the ado.Region field, then the ado.City field and add them to the list of Sort Fields. The records in the report will be sorted first by Region, then by City within each Region.

6Select each field in the Sort Fields list box, in turn, and verify that in ascending order is specified in the Order drop-down list.

7Select the Total Tab in the Create Report Expert. For each Region, your report will specify a subtotal of the Last Year’s Sales values.

8If ado.Last Year’s Sales does not appear in the Total Fields list box, select the field from the Report Fields list box and add it now.

9With ado.Last Year’s Sales selected in the Total Fields list box, verify that sum is selected in the drop-down list below.

10Click the TopN Tab to obtain the Top N regions. Top N of Sum of ado.Last Year’s Sales should already be selected in the tab.

11Change the 5 in the where N is text box to 10. Your report will display the top 10 regions.

12Click the Graph Tab to create a graph for the report. The Graph Expert appears inside the Graph Tab.

13Click the Pie button on the Type Tab, then proceed to the Data Tab.

14Review the settings on the Data Tab. A single graph will appear in your report that contains a separate pie slice for each grouping of the Region field. The sizes of the pie slices will be determined by the subtotal obtained by adding together the values in the Last Year’s Sales field.

15Click the Style Tab of the Create Report Expert. The Expert can automatically generate an overall style or look for your report.

16Select Executive, Leading Break, and notice the image next to the list. This is the look that your report will have.

17You have finished designing your first report in the Seagate Crystal Report Designer Component. Click Finish.

The Report Designer Component

154

Соседние файлы в папке crystal