Solved

Posted on 2013-06-07
337 Views
Just getting back into CF after a long layoff of about 10 years!

Trying out the cfspreadsheet tag. I have a query, and I am able to get the xls file to be saved on my server - I just want a prompt displayed for the user to either open or save the file - can this be done with cfspreadsheet??

Thanks for any help!
0
Question by:cb_it
[X]
###### Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

• Help others & share knowledge
• Earn cash & points
• 3

LVL 52

Accepted Solution

_agx_ earned 500 total points
ID: 39229124
No. cfspreadsheet only generates the file. Use cfcontent/cfheader to return it to the browser.

IIRC, there is one small nuisance w/cfspreadsheet. "query" and "name" are mutually exclusive, meaning you must save it to disk first.  Use a unique file name (to avoid clashes w/other downloads) -  something like createUUID() should work:

<cfset filePath = "c:\desired\path\to\#CreateUUID()#.xls">


then display it with cfcontent/cfheader. Use the "delete" attribute so the temp file will be removed automatically after the download (or shortly thereafter).

<cfheader name="Content-Disposition" value="attachment; filename=whateverNameYouWant.xls" >
<cfcontent type="application/vnd.msexcel" file="#filePath#" delete="true" >


EDIT If you use the spreadsheet functions, instead of the tag, you do not need to save it to a file. You can save it to a variable instead. Works better with small spreadsheets.

<cfset theSheet = SpreadSheetNew()>

0

Author Comment

ID: 39229829
Working perfectly, thanks. I wish the Adobe documentation was a little better, or gave more examples. I'm sure opening/saving the actual file is used quite a bit. Thanks again for the help.
0

LVL 52

Expert Comment

ID: 39229856
That's a common problem w/documentation.  It's too focused on explaining the single tag or function. Not enough common usage examples that show how to tie different things together.  I understand why ... it's involved. Takes a lot of time to put together good examples. (Nothing worse than a bad or broken example). Still .. would be nice to see more of them.
0

LVL 52

Expert Comment

ID: 39231740
(For the archives) Typo correction. The 2nd example should be:

... add query data to sheet ...
0

## Featured Post

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Sometimes databases have MILLIONS of records and we need a way to quickly query that table to return the results me need. Sure you could use CFQUERY but it takes too long when there are millions of records. That is why SOLR was invented. Please …
Recently while working on a project I got a very annoying cfdocument has no body error message. I had never seen this error before. So I checked the code. The code was pretty simple; it was Just showing me the cfdocumnt tag and inside that tag a …
In this video, viewers will be given step by step instructions on adjusting mouse, pointer and cursor visibility in Microsoft Windows 10. The video seeks to educate those who are struggling with the new Windows 10 Graphical User Interface. Change Cu…
There's a multitude of different network monitoring solutions out there, and you're probably wondering what makes NetCrunch so special. It's completely agentless, but does let you create an agent, if you desire. It offers powerful scalability …
###### Suggested Courses
Course of the Month10 days, 8 hours left to enroll