Cold Fusion Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 



Go Back   Dev Articles Community ForumsProgrammingCold Fusion Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
  #1  
Old July 1st, 2004, 01:08 PM
golgi1 golgi1 is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jul 2004
Posts: 1 golgi1 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Export to EXCEL- column naming

I'm exporting query data to excel, and it works fine, but I can't figure out how to name the columns in excel. Does anyone know???
Here's the script I'm using... and thx in advance,
-- G
------------------------------------
<cfquery name="CAP_Data" datasource="CAPFeedback">
select DISTINCT *
FROM Feedback
ORDER BY Feedback.date DESC
</cfquery>

<!-- calls excel -->
<cfcontent type="application/vnd.ms-excel">

<!-- sets default excel file name -->
<cfheader name="Content-Disposition" value="filename=Feedback_Report.xls">

<!-- build query loop -->
<table border="1">
<cfoutput query="CAP_Data">
<tr>
<td>#dateFormat(date, "mm/dd/yyyy")#</td>
<td>#rating#</td>
<td>#successful#</td>
<td>#name#</td>
<td>#city#</td>
<td>#state#</td>
<td>#phone#</td>
<td>#accomplish#</td>
<td>#worked#</td>
<td>#status#</td>
<td>#dateFormat(date_complete, "mm/dd/yyyy")#</td>
<td>#disposition#</td>
<td>#service_grp#</td>
<td>#disp_comment#</td>
</tr>
</cfoutput>
</table>

Reply With Quote
  #2  
Old July 7th, 2004, 08:59 PM
jackpoe jackpoe is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jul 2004
Posts: 1 jackpoe User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Wink The answer

Here is my own brand of how-to-do-this. It works perfectly.
Here you go! Have fun....


<cfquery datasource="YourODBCName" name="QueryName"> select * from tablename
</cfquery>
<cfif test.recordcount GTE 66000>
<!--- Excel can only handle 66000 rows --->
Too many records <cfelse>
<!--- create the file to be written --->
<cffile action="WRITE" file="c:\yourpathhere\data.cfm" output="
<cfcontent type='application/vnd.ms-excel'>
<table border='1'>
<tr> <td>ColumnName</td>
<td>ColumnName</td>
<td>ColumnName</td>
<td>ColumnName</td> </tr> " addnewline="Yes">
<!--- append the dynamic data to the file ---> <cfoutput>
<cfloop query="QueryName">
<cffile action="APPEND"
file="c:\yourpathhere\data.cfm" output=" <tr>
<td>#TRIM(ColumnName)#</td>
<td>#TRIM
(ColumnName)#</td>
<td>#TRIM(ColumnName)#</td>
<td>#TRIM(ColumnName)#</td> </tr> "
addnewline="yes">
</cfloop> </cfoutput>
<!--- end your table in the file --->
<cffile action="Append"
file="c:\yourpathhere\data.cfm" output="
</table> " addnewline="Yes">
<div align="center">
<font face="verdana, sans-
serif" size="2">
<strong>Your report has been
generated...<br>
<a href="data.cfm">Click here to complete the
download</a>
</strong>
</font>
</div>
</cfif>

Reply With Quote
  #3  
Old August 4th, 2004, 10:25 PM
brettr brettr is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Aug 2004
Posts: 1 brettr User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Nice example. Works great! Do you have one for uploading Excel into SQL Server?

Thanks,
Brett

Reply With Quote
  #4  
Old August 19th, 2004, 03:08 PM
kkhipple kkhipple is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jun 2004
Posts: 2 kkhipple User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Exclamation upload excel into sql server

Quote:
Originally Posted by brettr
Nice example. Works great! Do you have one for uploading Excel into SQL Server?

Thanks,
Brett



Bret

I believe the best method is to use the following method (it worked for me):
1. export excel to csv (tab or comma delimited)
2. then set up the csv file as a data source in the coldfusion admin page
3. set up a script that queries through the csv file and write code to do an insert into your sql server

Reply With Quote
  #5  
Old January 27th, 2005, 04:49 PM
mattyb_1978 mattyb_1978 is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jan 2005
Posts: 3 mattyb_1978 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 47 m 41 sec
Reputation Power: 0
The page seems to be compiling correctly and I've tested the table outputting to a .cfm page which works fine.
However as soon as I try and write to an Excel file I lose my table in to thin air (ie no output, a blank excel spreadsheet).
Here's my code:

<cfquery name="getReportDetails" datasource="CiPerformaSQL">
SELECT t1.RedemptionID, t2.Model, t2.AwardName, t1.Qty, SUM((t2.cost * t1.Qty) + t2.Est_Delivery) AS cost
FROM tblo_memberorders t1,
tblp_Awards t2
WHERE t1.AwardID = t2.AwardID
AND t1.Status = 1
AND t2.SupplierID = #Form.Supplier#
GROUP BY t1.RedemptionID, t2.Model, t2.AwardName, t1.Qty, cost
</cfquery>
<cfset totalCost = 0>

<cffile action="WRITE" file="orderForm.xls" output="
<cfcontent type='application/ms-excel'>

<table>
<tr>
<td><strong>RepemtionID</strong></td>
<td><strong>Model No</strong></td>
<td><strong>Product Name</strong></td>
<td><strong>Contact Name</strong></td>
<td><strong>Business Name</strong></td>
<td><strong>Address</strong></td>
<td><strong>Suburb</strong></td>
<td><strong>State</strong></td>
<td><strong>Postcode</strong></td>
<td><strong>Phone</strong></td>
<td><strong>Qty</strong></td>
<td><strong>Cost</strong></td>
</tr>" addnewline="Yes">

<!--- append the other data to the table --->
<cfloop query="getReportDetails">
<cffile action="APPEND" file="orderForm.xls" output="
<tr>
<td><cfoutput>#getReportDetails.RedemptionID#</cfoutput></td>
<td><cfoutput>#getReportDetails.Model#</cfoutput></td>
<td><cfoutput>#getReportDetails.AwardName#</cfoutput></td>
<td>Justine</td>
<td>CiEvents</td>
<td>115b Ferrars Street</td>
<td>South Melbourne</td>
<td>Victoria</td>
<td>3205</td>
<td>(03) 86967013</td>
<td><cfoutput>#getReportDetails.Qty#</cfoutput></td>
<td>$<cfoutput>#getReportDetails.cost#</cfoutput>
<cfset totalCost = totalCost + getReportDetails.cost></td>
</tr>" addnewline="Yes">
</cfloop>

<!--- end table in the file --->
<cffile action="APPEND" file="orderForm.xls" output="
<tr>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td><strong>Total Cost:</strong></td>
<td><strong>$<cfoutput>#totalCost#</cfoutput></strong></td>
</tr>
</table>" addnewline="Yes">
<h2>Your report has been generated...
<a href="orderForm.xls" target="_blank">Click here to complete the download</a></h2>

Please help me find my table as I'm lost without her!!!

Thanks in advance,

Matty

Reply With Quote
  #6  
Old April 12th, 2005, 10:16 PM
LukeWarmFusion LukeWarmFusion is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Apr 2005
Posts: 1 LukeWarmFusion User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 7 m 53 sec
Reputation Power: 0
Red face Maybe like this

I haven't tried it yet but saw your post and thought I should reply before I forget to. I believe your problem is the <cfcontent type='application/ms-excel'>. A cfm file would know how to interpret that but an excel file would not. Maybe if you tried it like #<cfcontent type='application/ms-excel'>#


<cffile action="WRITE" file="orderForm.xls" output="
<cfcontent type='application/ms-excel'>

Just a thought,

LukeWarm

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgrammingCold Fusion Development > Export to EXCEL- column naming


Developer Shed Advertisers and Affiliates


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.

© 2003-2018 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap