70 likes | 350 Views
In five easy steps... . First link from the calling page. <A HREF="rpt_ViewCustExcel.cfm" TARGET="rpt_ViewCustExcel"><b>EXCEL</b></A>. Second build the query. <CFQUERY NAME="FetchCustomerExcel" DATASOURCE="
E N D
1. Exporting to Excel with ColdFusion By Rick Mason, SeedChoices.com
2. In five easy steps…..
3. First link from the calling page <A HREF="rpt_ViewCustExcel.cfm" TARGET="rpt_ViewCustExcel">
<b>EXCEL</b></A>
4. Second build the query <CFQUERY NAME="FetchCustomerExcel" DATASOURCE="#S.db_Datasource#">
SELECT Customers.FName, Customers.LName, Customers.Address, Customers.City, Customers.State
FROM Customers
ORDER BY Customers.LName, Customers.FName
</cfquery>
5. Third call Excel using cfcontent <cfcontent type="application/vnd.ms-excel">
6. Fourth create the headers <cfoutput>
First_name#chr(9)#
Last_name#chr(9)#Address#chr(9)#
City#chr(9)#State#chr(13)#
</cfoutput>
7. Fifth send the data <cfoutput query="FetchCustomerExcel">
#fname##chr(9)##lname##chr(9)#
#Address##chr(9)##City##chr(9)##State#
#chr(13)#
</cfoutput>