BackUp LevelNext

Using CFREPORT for Crystal Reports Output

ColdFusion provides a simple tag syntax to integrate custom report formats created in Crystal Reports 5.0 or later into your application pages. This section describes the process from the ColdFusion side; consult your Crystal Reports documentation for the details of creating and managing reports.

To use this feature, follow these steps:

These steps assume that you have established an ODBC data source for ColdFusion on the Web server. The ColdFusion service calls the Crystal Reports engine to process the CFREPORT tag from a submitted application page. The formatted data set is included in the output to the browser.

Processing report requests from users can be time-consuming. CFREPORT is most efficient when used to publish reports to a static location.

Example: CFREPORT

ColdFusion allows tremendous flexibility in the runtime customization of Crystal Reports, including the ability to dynamically set the selection formula, sort order, target data source, and any custom formula within a report. The parameters you set in the CFREPORT tag take precedence over those in the report file.

Let's start with a simple example not based on any dynamic inputs:

<CFREPORT REPORT="d:\reports\myreport.rpt">
</CFREPORT>

In most cases, reports that you run will be based on criteria specified by the user or an application. The CFREPORT tag allows the specification of this criteria in a manner similar to the way the CFQUERY tag allows the specification of dynamic SQL statements.

The next example uses a function to determine the application page path. The report displays only those records that match ZIP code and last name criteria entered into an HTML form. The curly brackets enclosing the value names are required Crystal Reports syntax.

<CFREPORT REPORT="#GetDirectoryFromPath
    (Application PagePath)#myreport.rpt"
    {ZipCode}="#Form.ZipCode#" AND
    {LastName} LIKE "#Form.LastName#*"
</CFREPORT>

You can use the body of the CFREPORT tag to provide a custom report selection formula using Crystal Reports selection language. The following example illustrates all the tag's attributes. Note the use of the named formula "@Title" to specify the report name from form input.

<CFREPORT REPORT="#GetDirectoryFromPath
    (CF_application page_path)#myreport.rpt"
    DATASOURCE="CustomerReports
    USERNAME="TSEliot"
    PASSWORD="#Form.password#"
    FORMULA="#Form.ReportTitle#">
    ORDERBY="ZipCode">
        {ZipCode} = "#Form.ZipCode#" AND
        {LastName} LIKE "#Form.LastName#*" AND
        {FirstName} LIKE "#Form.FirstName#*"
</CFREPORT>

As with CFOUTPUT, conditional processing of data using CFIF, CFELSEIF, and CFELSE provides added flexibility to your output.


BackUp LevelNext

allaire

AllaireDoc@allaire.com
Copyright © 1998, Allaire Corporation. All rights reserved.