Skip to main content
June 7, 2007
Question

Database Query to Excel

  • June 7, 2007
  • 1 reply
  • 431 views
I have been working on getting data produced by a query to write to an Excel file (read all about it and saw sample code). Some just plain does not work, and then this is the closest I have gotten: See attached code.

When I run the application, the following happens in Firefox:

1. A pop--up error box appears that says: Internet Explorer cannot download "writeToExcel.cfm" from the server. Internet Explorer was not able to open this Internet site. The requested site is either unavailable or cannot be found. Please try again later. So I click "OK" and then refresh the page and then another box pops up asking if I want to open/save, etc and so I click "Open" and there it is.

If I run this application using IE - does not work at all. Just get the error message and then it simply fails.

The information I have in the CFML Reference book does not work at all.

Can someone please give me sure fire code that can work or explain the error of my ways? Also, in the CF Reference book, it says that to execute the CFCONTENT tag, it must be enabled in the CF Administrator - I do not see where I do that.

Thanks for any input.

Lee
    This topic has been closed for replies.

    1 reply

    Inspiring
    June 8, 2007
    I had absolutely NO problems running your code in both FF2 and IE6
    (CFMX7 on WinXP Pro/IIS).
    Which CF version and browser versions are you using?

    --

    Azadi Saryev
    Sabai-dee.com
    http://www.sabai-dee.com
    June 8, 2007
    Back at it this a.m. What I have discovered, that is if I try to preview the attached code in Dreamweaver, I get the error I listed in my initial post and then can hit refresh and get my excel data to appear properly. But if I create another page with a link to the page with the attached code which creates the Excel sheet, it works perfectly. Just trying to understand - any explanations?

    I have also changed the "inline" to "attachment". So when it is run with "attachment" instead of "inline", it asks whether to open or save it.:

    Is there anyway to avoid that and simply have the file saved somewhere without being prompted?

    Like I said, just trying to understand all this, but if it has to behave this way, I can work with it.

    Thank you for all your input.

    Lee
    Inspiring
    June 8, 2007
    quote:

    Originally posted by: LeeBC
    Back at it this a.m. What I have discovered, that is if I try to preview the attached code in Dreamweaver, I get the error I listed in my initial post and then can hit refresh and get my excel data to appear properly. But if I create another page with a link to the page with the attached code which creates the Excel sheet, it works perfectly. Just trying to understand - any explanations?



    That sounds like a dreamweaver/browser problem or maybe just caching. But does it really matter? Won't users be using the "link" method (ie. the one that works). That's the method you should test.

    quote:

    Originally posted by: LeeBC
    Is there anyway to avoid that and simply have the file saved somewhere without being prompted?



    No. For security reasons browsers are not allowed to do that (not without signed applets, activeX etc). Imagine if you weren't prompted, any site could download anything it wanted to your computer without your knowledge. You'd have no HD space available because it was filled with spam ;-)