MACROMEDIA COLDFUSION MX 61-DEVELOPING COLDFUSION MX Develop Manual page 832

Developing coldfusion mx applications
Table of Contents

Advertisement

To create an Excel spreadsheet with cfcontent:
Create a ColdFusion page with the following content:
1
<!--- use cfsetting to block output of HTML
outside of cfoutput tags --->
<cfsetting enablecfoutputonly="Yes">
<!--- get employee info --->
<cfquery name="GetEmps" datasource="CompanyInfo">
SELECT * FROM Employees
</cfquery>
<!--- set vars for special chars --->
<cfset TabChar = Chr(9)>
<cfset NewLine = Chr(13) & Chr(10)>
<!--- set content type to invoke Excel --->
<cfcontent type="application/msexcel">
<!--- suggest default name for XLS file --->
<!--- use "Content-Disposition" in cfheader for
Internet Explorer
<cfheader name="Content-Disposition" value="filename=Employees.xls">
<!--- output data using cfloop & cfoutput --->
<cfloop query="GetEmps">
<cfoutput>#Employee_ID##TabChar##LastName#
#TabChar##FirstName##TabChar##Salary##NewLine#</cfoutput>
</cfloop>
Save the file as employees_to_excel.cfm in the myapps directory under your web_root and view
2
it in the browser.
The data appears in an Excel spreadsheet:
832
Chapter 37: Managing Files on the Server
--->

Advertisement

Table of Contents
loading
Need help?

Need help?

Do you have a question about the COLDFUSION MX 61-DEVELOPING COLDFUSION MX and is the answer not in the manual?

Questions and answers

This manual is also suitable for:

Coldfusion mx

Table of Contents