Copy link to clipboard
Copied
Hi
Here is the code I got and modified from the internet
<cfsetting enableCFOutputOnly="Yes">
<cfquery datasource="#dsn#" name="getInfo">
SELECT distinct route
FROM empDB
where route > 100 and route < 4999
order by route asc
</cfquery>
<cfset tabChar = chr(9)>
<cfset newLine = chr(13) & chr(10)>
<cfheader name="Content-Disposition" value="filename=pay1.xls">
<cfcontent type="application/msexcel">
<cfoutput>Street Number#tabChar#Street Name#newLine#</cfoutput>
<cfloop query="getFilms">
<cfoutput>#streetNumber##tabChar##streetName##newLine#</cfoutput>
</cfloop>
When I run the code, i get Error: "internet explorer cannot download math.cfm from www.brantnews.com"
anyone got any ideas why
Thanks
Craig
Copy link to clipboard
Copied
Craig,
A couple of things to try:
1. Change the type attribute of the cfcontent tag to either 'application/unknown' and/or 'text/plain'
2. The downside is that you'd have to re-write a bit of code but check out Ben Nadel's POI CFC project I use this utility for all Excel files. Basically, you can easily create an Excel file, write it to the server and provide a download link. It's worked consistently for me across browsers and applications.
Copy link to clipboard
Copied
If the template is named math.cfm, the problem might be that excel 2007 does not like excel content created this way. There is a cfc out there that you can use to create actual excel files and this works a lot better. To find it, google "coldfusion export to excel poi"
Copy link to clipboard
Copied
Does the code run without error (save the Excel file to disk instead of delivering it to the browser for the purposes of testing) if you run it without the <cfheader> / <cfcontent> lines?
--
Adam
Copy link to clipboard
Copied
try:
<cfheader name="Content-Disposition" value="attachment; filename=yourfile.xls">
HTH
Melvin T.
Copy link to clipboard
Copied
Thanks alot everyone
I tried a few of the things and nothing by itsself worked but when I removed the cfcontent/cfheader I noticed a invalid field in one of the querys, once I removed that the process worked.
again, thanks alot.
Craig