[thelist] Export page to excel

Ron Thigpen rthigpen at nc.rr.com
Mon Jun 17 14:23:01 CDT 2002


I've done this a few times using Cold Fusion.  My method works fine for
simple tabular data and doesn't involve mucking about with COM.

Basically, you need to do two things: convince the browser that the
response is an Excel file, and do a reasonably good job of imitating the
Excel file format.

For the first, your script will need to send a content type header of
"application.vnc.ms-excel"  Different scripting languages will have
various ways to accomplish this.

For the second, you'll just need to format your data as tab delimited.

Here's a code snippet.

<cfheader name="Content-disposition" value="attachment;
filename=spreadsheet.xls">
<cfcontent type="application/vnd.ms-excel">Field1 Field2 Field3
<cfoutput query="getDat">#Field1# #Field2# #Field3#
</cfoutput>


Make sure that the separation between fields is a tab character.
Otherwise this will fail.

--rt


Amazon Paulo wrote:
>
> How can I put a button in the page so when the user clicks is, the script
> will export all the content in the tables to an Excel file? (Can this be
> done?)






More information about the thelist mailing list