<cfquery> to Excel

Is it possible to execute a query in Coldfusion and to export the result of that query to an Excel spreadsheet? Is there example code for this?
Gregory AmbroseAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

erikTsomikSystem Architect, CF programmer Commented:
One of the Technics can be found here http://christopherstoll.org/2008/02/coldfusion-excel-export.html

Also depending on the version of CF you can use cfspreadsheet explained here

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Gregory AmbroseAuthor Commented:
Maybe I misunderstand these references but they seem to deal with the spreadsheet is input or the source of data.

I am looking to use a coldfusion query to retrieve  a bunch of email addresses from a SQL database and the output them to a csv file for use in Excel.
erikTsomikSystem Architect, CF programmer Commented:
That exactly what is doing you are writing a query and exporting them into Excel
Gregory AmbroseAuthor Commented:
A tad confusing but I got thru it.
@GregoryAmbrose - If you used option #1, just be aware later versions of Excel are a lot less lenient about that technique than they used to be.  So Excel may display a warning when a user opens the the file.  It's due to a new security feature called "Extension Hardening". Users are warned when the file content doesn't match the file extension.  In this case the content is HTML, but the file extension claims it is an .XLS file:

        <cfcontent type="application/msexcel">

The solution is to make sure the extension matches the content. Either by using option #2 instead (generate an binary Excel file) OR by generating a CSV file and using <cfcontent type="Content-type: text/csv">
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Excel

From novice to tech pro — start learning today.