Have a look at using Apache POI, which is in CF7 already. This will create
Excel sheets using Java which is far more efficient than using HTML to mimic
a sheet.

You could also look at using DTS if you are on SQL Server to export the
results to Excel.






"This e-mail is from Reed Exhibitions (Gateway House, 28 The Quadrant,
Richmond, Surrey, TW9 1DN, United Kingdom), a division of Reed Business,
Registered in England, Number 678540.  It contains information which is
confidential and may also be privileged.  It is for the exclusive use of the
intended recipient(s).  If you are not the intended recipient(s) please note
that any form of distribution, copying or use of this communication or the
information in it is strictly prohibited and may be unlawful.  If you have
received this communication in error please return it to the sender or call
our switchboard on +44 (0) 20 89107910.  The opinions expressed within this
communication are not necessarily those expressed by Reed Exhibitions." 
Visit our website at http://www.reedexpo.com

-----Original Message-----
From: Pete
To: CF-Talk
Sent: Sun Mar 18 03:36:28 2007
Subject: Create an Excel Spreadsheet

Hi there

 

I have got a CF program which is working fine.  I'd just like to try and
improve the program.

 

Basically it has been developed to export the results of a query to an excel
spreadsheet (which it is doing).

 

I'm just wondering if there is a way so as to create the first row in the
spreadsheet which contains column names.

 

Here is the code which I have got:

 

<!--- Use cfsetting to block output of HTML outside of cfoutput tags --->

 

<cfsetting enablecfoutputonly="yes">

 

<!--- get medical delegate information --->

 

<cfquery name="qgetmedicaldelegates" datasource="#request.db_dsn#"
username="#request.db_login#" password="#request.db_pwd#">

SELECT                      *

FROM                         tbl_meddelregos

</cfquery>

 

<!--- set vars for special characters --->

<cfset TabChar = Chr(9)>

<cfset NewLine = Chr(13) & Chr(10)>

 

<!--- set content type to invoke Excel --->

 

<cfcontent type="application/msexcel">

 

<!--- Suggest default name for XLS file --->

 

<!--- use "Content-Disposition" in cfheader for Internet Explorer --->

 

<cfheader name="Content-Disposition" value="filename=medicaldelegates.xls">

 

<!--- Output data using cfloop & cfoutput --->

<cfloop query="qgetmedicaldelegates">

<cfoutput>

#ID##TabChar##Title##TabChar##FirstName##TabChar##LastName##TabChar##PrefNam
e##TabChar##BusName##TabChar##Address##TabChar##Suburb##TabChar##StateID##Ta
bChar##Postcode##TabChar##CountryCode##TabChar##Phone##TabChar##Fax##TabChar
##Mobile##TabChar##Email##NewLine#

</cfoutput>

</cfloop>

 

Thanks in advance

 

P






~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Upgrade to Adobe ColdFusion MX7
The most significant release in over 10 years. Upgrade & see new features.
http://www.adobe.com/products/coldfusion?sdid=RVJR

Archive: 
http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:272925
Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4

Reply via email to