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 January 27th, 2005, 04:58 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
Question Exporting dynamic query to Excel

I'm trying to query a database and write the results to an Excel spreadsheet.

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 spreadsheet).
Here's my code:

<cfquery name="getReportDetails" datasource="myDataSourceName">
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>

<!--- write the column headers --->
<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
  #2  
Old March 7th, 2005, 10:14 AM
pruszaj pruszaj is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Mar 2005
Posts: 1 pruszaj User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 14 m 52 sec
Reputation Power: 0
This is how I accomplished the task...

<cfset TabChr = Chr(9)>


<cfset Heading= ListChangeDelims(#lookuppeople.ColumnList#,"#TabChr#", ",")>
<cffile action="write" file="i:\web-docs\qopboard\reports\#auth_user##dateformat(Now() ,"mm-dd")##timeformat(now(),"hh-mm")#.xls"
output="#Heading#"
ADDNEWLINE="Yes">

<cfset temp = "">
<cfloop query="lookuppeople">
<cfloop index="X" LIST="#lookuppeople.ColumnList#">
<cfset temp= ListAppend(temp, #evaluate(x)#,#TabChr#)>
</cfloop>
<cffile ACTION="Append"
FILE="i:\web-docs\qopboard\reports\#auth_user##dateformat(Now() ,"mm-dd")##timeformat(now(),"hh-mm")#.xls"
OUTPUT="#temp#"
ADDNEWLINE="Yes">
<CFSET temp = "">
</cfloop>
<br>
Report file is located <a href="<A href="http://infonet.ahc.comqopboardreportsahc">here</a">http://infonet.ahc.com\qopboard\reports\ahc">here</a>.

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgrammingCold Fusion Development > Exporting dynamic query to Excel


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




 Free IT White Papers!
 
Create the Optimal Architecture for your Critical Applications
Warburton's the largest independently owned bakery in the UK faced a number of difficult challenges in providing the most robust yet efficient IT infrastructure for their organization's success. IBM's services combined with their xSeries servers created the perfect platform for their SAP environment with sufficient flexibility, and did so in very time effective fashion.

Request Your Free Technology Downloads!
 
Five Best Practices for Deploying a Successful Service-Oriented Architecture
This white paper describes the benefits you can expect with SOA, and how IBM can help take your business there.

Request Your Free Technology Downloads!
 
Gartner Magic Quadrant for Application Delivery Controllers
Gartner summarizes its view on Application Delivery Controllers, evaluates strengths and weaknesses of solutions, and provides Magic Quadrant reporting for a quick comparison across all vendors. Learn from Gartner how you can benefit from an all-in-one device like Citrix NetScaler that delivers the highest levels of availability, performance and security.

Request Your Free Technology Downloads!
 
Knowledge is Power
What you don't know can hurt you, and is likely costing you money and increasing your security risks during an era of scarce resources. This white paper proposes six key strategies that enterprise security managers can use to improve their network defense posture.

Request Your Free Technology Downloads!
 
Rationalizing the Multi-Tool Environment
The rationalized multi-tool approach is flexible, scalable and cost effective. It provides the necessary input to the IT service management business processes. It preserves prior investments in monitoring tools, empowers technologists to select the best tools with which to do their jobs, and enhances effective response to incidents.

Request Your Free Technology Downloads!
 

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




© 2003-2010 by Developer Shed. All rights reserved. DS Cluster 11 Hosted by Hostway
For more Enterprise Application Development news, visit eWeek