#1
  1. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2003
    Posts
    1
    Rep Power
    0

    send data as an excel file


    Hi,
    Can any one lemme know how to send data in excel sheet using Cold Fusion.

    Thanks & regards,
  2. #2
  3. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2003
    Posts
    5
    Rep Power
    0
    You might be able to try this. This will display a query in excel.

    <cfquery name="test" datasource="yourdsn">
    SELECT first_name, last_name, age FROM students
    </cfquery>

    <cfif test.recordcount GTE 66000>
    Too many records! <cfabort>
    </cfif>

    <cffile action="write" file="c:\inetpub\wwwroot\coldfusion\newrockenbach\codesnippet\data.cfm" output="
    <cfcontent type='application/vnd.ms-excel'>
    <table border='1'>
    <tr>
    <td>First Name</td>
    <td>Last Name</td>
    <td>Age</td>
    </tr> " addnewline="Yes">

    <cfoutput>
    <cfloop query="test">
    <cffile action="append" file="c:\inetpub\wwwroot\coldfusion\newrockenbach\codesnippet\data.cfm" output=" <tr>
    <td>#trim(first_name)#</td>
    <td>#trim(last_name)#</td>
    <td>#trim(age)#</td>
    </tr> " addnewline="Yes">
    </cfloop>
    </cfoutput>

    <cffile action="append" file="c:\inetpub\wwwroot\coldfusion\newrockenbach\codesnippet\data.cfm" output="</table> " addnewline="Yes">
    <div align="center">
    <b>Your report has been generated...<br></b>
    <a href="data.cfm">Click here to complete the download</a>
    </div>

IMN logo majestic logo threadwatch logo seochat tools logo