<!--- 
 Filename: FilmsToExcel.cfm
 Author:  Nate Weiss (NMW)
 Purpose: Outputs film information for Microsoft Excel
--->

<!--- Don't output anything *not* in CFOUTPUT tags --->
<!--- This makes it easier to deal with whitespace --->
<cfsetting enableCFOutputOnly="Yes">

<!--- Retrieve information about films --->
<cfquery datasource="ows" name="getFilms">
 SELECT MovieTitle, AmountBudgeted
 FROM Films
 ORDER BY MovieTitle
</cfquery>

<!--- Set variables for special characters --->
<cfset tabChar = chr(9)>      
<cfset newLine = chr(13) & chr(10)>

<!--- Suggest default filename for spreadsheet --->
<cfheader name="Content-Disposition" value="filename=FilmBudgets.xls">
<!--- Set the content-type so Excel is invoked --->
<cfcontent type="application/msexcel">

<!--- Output the header row, with column names --->
<!--- Put tab between columns, and newline at end --->
<cfoutput>MOVIE TITLE#tabChar#BUDGET#newLine#</cfoutput>
<!--- Output actual data rows, each on own line --->
<!--- Put tab between columns, and newline at end --->
<cfloop query="getFilms">
 <cfoutput>#MovieTitle##tabChar##AmountBudgeted##newLine#</cfoutput>
</cfloop>
