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

Posted on 2006-03-24
Last Modified: 2013-12-24

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.
Question by:g118481
    LVL 24

    Accepted Solution

    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
    LVL 1

    Author Comment

    I cannot use the cfcontent tag on my host site.
    Is there another way to export my cfquery to excel?
    LVL 24

    Expert Comment

    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 ...

    Featured Post

    Highfive Gives IT Their Time Back

    Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

    Join & Write a Comment

    This is a guide to setting up a new WHM/cPanel Server to be used for web hosting accounts. It is intended for web hosting company administrators and dedicated server owners. For under $99 per month (considering normal rate of Big Data Cetnters like …
    When it comes to showing a 404 error page to your visitors, you do not want that generic page to show, and you especially do not want your hosting provider’s ad error page to show either. In this article, I will show you how to enable the custom 40…
    To add imagery to an HTML email signature, you have two options available to you. You can either add a logo/image by embedding it directly into the signature or hosting it externally and linking to it. The vast majority of email clients display l…
    Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

    746 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    12 Experts available now in Live!

    Get 1:1 Help Now