Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Export to Excel 2

Status
Not open for further replies.

TSO456

Technical User
Jul 23, 2001
57
US
Hello,

I use CFGRID to display data from a SQL database. I would like to be able to export the output to excel after I view the GRID. Any suggestions will be greatly appreciated.

Thanks
 
This worked fine for me.

<CFFILE contentType=&quot;application/x-msexcel&quot;
action=&quot;write&quot;
file=&quot;C:\inetpub\output =
'
<table border=1>
<td><b>Phone</b></td>
</tr></table>
'>
<!---Append to the existing file, pour data in corresponding headers---
<cfloop query=&quot;getPHONE&quot;>
<CFFILE
contentType=&quot;application/x-msexcel&quot;
action=&quot;append&quot;
file=&quot;c:\inetpub\output =
'
<table border=1>
<tr><td>#QUERY_NAME.phone#</td></tr><TAble>
'></cfloop>

<cfif SOME CONDITION>
<CFOUTPUT>
<cfheader name=&quot;Content-Disposition&quot; value=&quot;download; filename=ExcelReport&quot;>
<cfcontent type=&quot;application/msexcel&quot; file=&quot;File.xls&quot; deletefile=&quot;no&quot;>
</CFOUTPUT>
</cfif>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top