Here's what I use with the help of a lot of feedback from the board.
There are two <cfcontent> and <cfoutput> tags. The first one will
display the headers at the top of the .xls file and the 2nd group
outputs the data from query. Make sure that Reset is Yes on the 1st
<cfcontent> but Reset is No on the 2nd. This why it won't wipe out the
results of the 1st <cfcontent>.
Also, I had to take out all the spaces within the <output> tags EXCECT
for the very last space before the closing </cfoutput>. Otherwise, all
the content ran together on one line.
Hope it helps!
<cfset todayDate = Now()>
<cfset saveDate = DateFormat(todayDate,('yymmdd'))>
<cfset saveTime = TimeFormat(todayDate,('HHmm'))>
<CFSET TAB=CHR(9)>
<CFSETTING ENABLECFOUTPUTONLY="yes">
<CFQUERY NAME="get_Data" DATASOURCE="myDatabase">
SELECT Registration_Type, Name_First, Name_Last, Title,
Group_Company, Address, City, Phone, Fax, Spouse
FROM data
</CFQUERY>
<CFHEADER NAME="Content-Disposition" VALUE="inline;
filename=contact-#saveDate#-#saveTime#.xls">
<CFCONTENT RESET="Yes" TYPE="application/msexcel"><cfoutput>Registration
Type#TAB#First Name#TAB#Last
Name#TAB#Title#TAB#Company/Group#TAB#Address#TAB#City#TAB#Phone#TAB#Fax#
TAB#Spouse#TAB#
</cfoutput>
<CFCONTENT RESET="No" TYPE="application/msexcel"><CFOUTPUT
QUERY="get_Data">#Registration_Type##TAB##Name_First##TAB##Name_Last##TA
B##Title##TAB##Group_Company##TAB##Address##TAB##City##TAB##Phone##TAB##
Fax##TAB##Spouse##TAB#
</CFOUTPUT>
At 11:39 AM 1/17/2005, you wrote:
>Hi Friends
>i want to save the data return by the cfquery into excel . and give
link
>to downlaod the excel file or save dailog box should open to save the
file
>in excel format
>
>i tried in may ways . its display the data in the browser but not able
to
>downlaod as excel
>
>pls suggest me how to do this
>
>Thanks in advance
>vishnu
>
>
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Discover CFTicket - The leading ColdFusion Help Desk and Trouble
Ticket application
http://www.houseoffusion.com/banners/view.cfm?bannerid=48
Message: http://www.houseoffusion.com/lists.cfm/link=i:4:191093
Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4
Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
Donations & Support: http://www.houseoffusion.com/tiny.cfm/54