Adobe ColdFusion 8

Displaying reports

Your application can invoke a report by displaying the CFR file in a browser or by displaying a CFM page whose cfreport tag invokes the report.

You can optionally use the cfreport tag to save the report to a file.

The cfreport tag supports advanced PDF encryption options. For more information, see cfreport in the CFML Reference.

For information on report preview, see Previewing reports.

Display a report by using the cfreport tag

  1. Create a report, with or without an internal query.
  2. Create a CFM page and add a cfreport tag that invokes the report. If the report does not use an internal query, you must also populate a query and pass it using the query attribute. If the report uses an internal query and you use the query attribute, the passed query overrides the internal query.
    <cfquery name="northwindemployees" datasource="localnorthwind">
        SELECT EmployeeID, LastName, FirstName, Title, City, Region, Country
        FROM Employees
        ORDER BY Country, City
    </cfquery>
    
    <CFREPORT format="PDF" template="EmpReport.cfr" 
     query="#northwindemployees#"/>
    

    Note: ColdFusion does not render text that occurs before or after the cfreport tag.

  3. Open a browser and display the CFM page.

    ColdFusion generates the report.

Display a CFR file in a browser

  1. Create a report that uses an internal query and does not use input parameters.
  2. Open a browser and display the CFR file.

Save a report to a file

  1. Create a report, with or without an internal query.
  2. Create a CFM page and add a cfreport tag that invokes the report. Optionally pass a query attribute, as described in the previous procedure. Include a filename attribute that specifies the fully qualified name of the file to be created, as the following example shows:
    <CFREPORT format="PDF" template="emppicture.cfr" 
        filename="#GetDirectoryFromPath(GetTemplatePath())#/emppicture.pdf"
    	overwrite="yes"/>
    

Use the .pdf extension for PDF output format, the .swf extension for FlashPaper output format, .xml extension for an XML file, .rtf extension for an RTF file, .html extension for HTML files, and the .xls extension for Excel format.

  1. Open a browser and display the CFM page. ColdFusion generates the report, saves the file, and displays an empty page in the browser.

Disable browser display of the CFR file

  1. Open the Report Properties dialog box by selecting Report > Report Properties from the menu bar.
  2. Clear the Allow Direct .CFR Browser Invocation option, and click OK.