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 CFML Reference and Using advanced PDF options.

For information on report preview, see Previewing reports.

To display a report 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#" />
    
  3. Open a browser and display the CFM page.

    ColdFusion MX generates the report.

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

To 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.

    ColdFusion MX generates the report.

To 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"/>
    

    Tip: Use the .pdf extension for PDF output format, the .swf extension for FlashPaper output format, and the .xls extension for Excel format.

  3. Open a browser and display the CFM page.

    ColdFusion MX generates the report, saves the file, and displays an empty page.

To 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 check box.
  3. Click OK.

View comments in LiveDocs