Reporting Formats


ColdFusion MX 7 not only enables you to create stunning, dynamic reports based on your database content, but it also enables you to provide these reports to your users in a variety of formats. In fact, you can display the same report in multiple formats in a snap. After you create a report, just add the appropriate tag to your web page and ColdFusion does the rest.

PDF Reports

One of the most popular formats for displaying reports via a web browser is the Adobe Portable Document Format (PDF). This file format enables you to package a document in a single file that can be emailed, stored on disk, or displayed on your website with the free Adobe Acrobat Reader application that is available via Adobe's website.

To create a report that uses the PDF format, all you need to do is add the <cfreport> tag to your page and set the format to PDF. For instance, the following code would call a report named retros_customers.cfr:

<cfreport template = "artist_19.cfr" format = "PDF"></cfreport>


Note

When you specify the template location for your report, the filename is relative to your site's web root.


That's it! Just save your page and view it in your browser (see Figure 19.26).

Figure 19.26. A report created in the PDF format, using the ColdFusion Report Generator.


Before we move on to the next format, it would probably be good to mention the various attributes that you can add to the cfreport tag when generating reports:

  • Name Enables you to specify the name of a ColdFusion variable that holds report output.

  • Filename Used instead of the Name attribute, it enables you to specify a filename that will contain the report after it is generated.

  • Query Enables you to specify a SQL query if one has not been embedded in the report.

  • Overwrite Specifies whether or not files that already exist can be overwritten.

  • Encryption Used for PDF reports only, this attribute can be set to 128-bit, 40-bit, or none.

  • Ownerpassword Enables you to set a password for owners on a PDF report.

  • Userpassword Enables you to set a password for users on a PDF report.

  • Permissions Specifies eight different permission levels for PDF reports (AllowPrinting, AllowModifyContents, AllowCopy, AllowModifyAnnotations, AllowFillIn, AllowScreenReaders, AllowAssembly, and AllowDegradedPrinting).

FlashPaper Reports

Another option for creating reports in ColdFusion is the FlashPaper format developed by Macromedia. This format converts your document into a Flash movie that can be viewed with the Macromedia Flash Player. Creating a FlashPaper report is just as easy as creating one in the PDF format. Just use exactly the same code you used for the PDF format and adjust the format attribute:

<cfreport template = "retros_customers.cfr" format = "FlashPaper"></cfreport>


Again, view the document in your browser and the Flash Player renders the report (see Figure 19.27).

Figure 19.27. A report created in the FlashPaper format, using the ColdFusion Report Generator.


Microsoft Excel Reports

The final format that the ColdFusion Report Generator is able to create is the Microsoft Excel format (see Figure 19.28). Where the PDF and FlashPaper reports are generally read-only, the Excel format offers access to data, and reports can be saved and edited offline. As with FlashPaper and PDF, generating an Excel report is as simple as adjusting the format attribute:

Figure 19.28. A report created in the Excel format, using the ColdFusion Report Generator.


<cfreport template = "retros_customers.cfr" format = "Excel"></cfreport>


Be aware, however, that there are some limitations as to how well your formatting will be retained in the Excel format. Objects such as images and charts may not render properly, and numeric data that contains special characters such as commas, percent signs, and dollar signs might cause issues in the generation of the report.



Special Edition Using Macromedia Studio 8
Special Edition Using Macromedia Studio 8
ISBN: 0789733854
EAN: 2147483647
Year: 2003
Pages: 337

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