Additional Reporting Options


Beyond the basic reporting functionality reviewed this far, the ColdFusion Report Writer and the reporting engine also supports a wide range of reporting features (more than can be included in this review chapter). Here are some key features worth noting:

Saving Generated Reports

Like printable pages generated using <cfdocument>, reports generated via <cfreport> may be saved (instead of served) by specifying a filename.

Passing Input Parameters

In addition to being able to pass a query to <cfreport> at runtime, name=value variable pairs may also be passed in one of two formats, as <cfreport> attributes:

 <!--- Generate report ---> <cfreport template="userList.cfr"           query="users"           format="PDF"           title="Sales Department Employees" /> 

or via <cfreportparam> tags:

 <!--- Generate report ---> <cfreport template="userList.cfr"           query="users"           format="PDF">   <cfreportparam name="title"                  value="Sales Department Employees" /> </cfreport> 

These examples are functionally identical, and both pass a input parameter named title to the report.

To use this input parameter is must be defined in the report (in the Fields and Parameters panel). Once defined, input parameters can be used like any other report fields or expressions.

Conditional Element Processing

All report element (fields, labels, embedded charts, and more) are included by default (after all, if they are defined in the report then they should be included in it). But all report elements may be included or excluded at runtime based on a CFML expression. To do this, click on an element and specify a condition in the Print When property. For example, to include a chart only on Monday's, embed the chart, and then associate this condition with it:

 DayOfWeek(Now()) IS 2 

Report elements can also be included or excluded based on input parameters. For example, to conditionally include or exclude a logo add define an input parameter named dispLogo of type boolean with a default of 1, and then use the following as the Print When condition:

 param.dispLogo 

This way the logo will be included in the report unless dispLogo=false is passed at runtime.

Embedding Subreports

To embed a subreport within a report, click on the subreport button and define where within the report it is to be placed. You will be prompted to either create a new report or to select an existing report. Either way, the subreport will be opened in a second tab allowing you to work on both the main report and the subreport simultaneously.

NOTE

It is not yet possible to pass queries at runtime to subreports, subreports always use embedded SQL.


Using Text Styles

Text styles allow styles to be used for text and labels instead of hard-coding these settings. Text styles are defined in the Text Styles tab, and are associated with report elements by selecting the style from the Text Styles drop down list in the Properties panel.

NOTE

<cfreport> still supports the use of Crystal Reports .rpt files as it did in previous ColdFusion versions. However, that support is primarily for backwards compatibility, and the primary reporting emphasis now is on the reporting engine and the ColdFusion Report Builder.




Macromedia ColdFusion MX 7 Certified Developer Study Guide
Macromedia ColdFusion MX 7 Certified Developer Study Guide
ISBN: 0321330110
EAN: 2147483647
Year: 2004
Pages: 389
Authors: Ben Forta

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net