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 ReportsOne 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:
FlashPaper ReportsAnother 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 ReportsThe 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. |