Home > coldfusion > How to export data as Excel format in Cold Fusion

How to export data as Excel format in Cold Fusion

I’m trying to export all of data in my table in excel format by using Cold Fusion. I thought it would be complicated and hard to implement. After reading through Cold Fusion documents, it’s as easy as ABC. Here is sample coding :

<cfheader name=”Content-Disposition” value=”inline; filename=GiftLists.xls”>
<cfcontent type=”application/vnd.msexcel”>

<cfquery name=”PMQry” datasource=”#application.ds#” username=”#application.un#” password=”#application.pw#”>
SELECT P_Name, Org_Name FROM Persons
LEFT JOIN Organizations ON Org_ID = P_Organization
</cfquery>

<table border=”2″>
<tr>
<th>No.</th>
<th>Name</th>
<th>Organi</th>
</tr>
<cfoutput query=”PMQry”>
<tr>
<td>#currentrow#.</td>
<td>#P_Name#</td>
<td>#Org_Name#</td>
</tr>
</cfoutput>
</table>

How? It’s kinda easy, isn’t it?

Categories: coldfusion
  1. No comments yet.
  1. No trackbacks yet.
You must be logged in to post a comment.