Opening an excel file in ColdFusion 8

onaled777
onaled777 used Ask the Experts™
on
With the code below I am attempting to open an excel file when the submit button of a form is pressed by I keep getting a page with the following on the first line:

'); } } function writeCloseBody() { if( debugMode ) { document.write('

Can someone show me how to correct this?


<cfsetting enablecfoutputonly="Yes">
 
 
<cfparam name="publisher">	
<cfparam name="productcode">		
<cfparam name="campaign">
<cfparam name="cpa">
<cfparam name="exiturl">
<cfparam name="MOJOCreativeID">
<cfparam name="MOJOPlacementID">
<cfparam name="PageID">
<cfparam name="PageWght">
<cfparam name="CampaignCount">
 
 
<cfif isDefined("Form")>
	<cfset publisher = Form.publisher>
	<cfset product_code = Form.productcode>
	<cfset campaign_name = Form.campaign>
	<cfset cpa = Form.cpa>
	<cfset exit_url = Form.exiturl>
</cfif>
 
 
 
<cfcontent type="application/msexcel">
 
<cfheader name="Content-Disposition" value="filename=BulkCampExcel.xls">
 
	<cfoutput>
		<table cols="2">
			<tr>
				<th>publisher</th>	
				<th>product_code</th>		
				<th>campaign_name</th>
				<th>cpa</th>
				<th>exit_url</th>
				<th>MOJOCreativeID</th>
				<th>MOJOPlacementID</th>
				<th>PageID</th>
				<th>PageWght</th>
			</tr>
		<cfloop index = "LoopCount" from = "1" to = "#CampaignCount#">
			<tr>
				<td>#publisher#</td>	
				<td>#productcode#</td>		
				<td>#campaign#</td>
				<td>#cpa#</td>
				<td>#exiturl#</td>
				<td>#MOJOCreativeID#</td>
				<td>#MOJOPlacementID#</td>
				<td>#PageID#</td>
				<td>#PageWght#</td>
			</tr>
		</cfloop>
	</table>
</cfoutput>

Open in new window

Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Pravin AsarPrincipal Systems Engineer
Top Expert 2005

Commented:
Principal Systems Engineer
Top Expert 2005
Commented:
Add "attachment; " 

Also you have option to suppress cfoutput and/or debug output


<cfsetting enablecfoutputonly="Yes">
<cfsetting showdebugoutput="false" />
<cfcontent type="application/msexcel">
<cfheader  name="Content-Disposition" value="attachment; filename=BulkCampExcel.xls">

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial