How to have a query output to Excel without listing every field?


I have two parts to this question:
1.  How can I export my query to Excel when the user clicks on the link to the page with the query in it.
2.  Is it possible to not have to list all the fields in the query for the output on the query page?

I Have some simple reports to do.  The table has probably about 40 fields.
I do not want to list the query and then list all the fields in the query for output.
I want to do the list of the query results dynamically.
Who is Participating?
Try this on the page you want to export to excel
<cfcontent type="application/excel">
<cfheader name="Content-Disposition" value="filename=Results.xls">

Do you mean for part 2 that you want to display x number of fields on your query page, but not export all of them to excel?
If thats what you mean then on your query page you'll have a link that says "click here to output to excel" or whatever
add a target value to the link which would be a hidden iFrame where you do a different query that contains only the fields you want output to excel.
The above cfcontent & cfheader would need to be on this hidden iFrame page
g118481Author Commented:
I cannot use the cfcontent tag on my host site.
Is there another way to export my cfquery to excel?
not that I know of using ColdFusion.
Although there may be a custom tag available somewhere.
But if your host won't allow cfcontent, then they probably don't allow custom tags.

Get a new host!
There are several very affordable ColdFusion hosts who do not put restrictions on you.
Your current host not allowing certain tags really means that they don't know how to configure each customers sandbox correctly so they just apply a blanket restriction.

Good luck ...
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.