Hello there, I just bought a book to learn ColdFusion, so I have a project but I wonder if the following is possible:

To create a page where the user can select:
1 - Date Range
2 - Report Name
3 - select to export to Excel, and here is the trick, when the user select the "Export to Excel' buttom, it opens in Excel. So, is possible to make it to open a Template in Excel where I will have a tab with a macro button on it to create a Pivot Table? So, if the user select the report and export it, instead opening in regular Excel, it will open this Template with the macro, and the macro will pick up the data and create a Pivot Table, is this possible in CF? I just started so I just want to make sure that I don't waste my time trying to do it.
Tks
Liz

Yes it's possbible don't know about the template part but depending where you are pulling the data from you can select a date then download the data to excel here is any example that pulls data from a database then open's it in excel.

<cfinclude template="session_check.cfm">
<cfquery name="rs_Search" datasource="#application.dsn#">
SELECT *
	FROM _Get_Estimates
WHERE     (DateTimeStamp > '3/31/2006 23:23:59')
order by datetimestamp DESC
</cfquery>

  <!--- create new query for the Excel spreadsheet --->
  <cfset New = QueryNew("FName,LName,Address1,City,State,Zip,Phone,Email,Estimated_LotSize,LawnTreatment,FullAeration,SpotAeration,PestControl,GrubControl,MoleControl,PerimeterPestControl,fallProgram,sourceCode,HeardAboutHL,Redirect,LeadPurchase,Comments,Contacted,DateTimeStamp")>
	
  <!--- Loop through the query to fill the new query --->
 <cfoutput>
  <cfloop query="rs_Search">
	<cfif rs_Search.Contacted IS 1><cfset variables.Contacted = "YES"><cfelse><cfset variables.Contacted = "NO"></cfif>
 <!---  add rows to query --->
  <cfset QueryAddRow(New)>
	  <cfset QuerySetCell(New,"FName", rs_Search.FName)>
	  <cfset QuerySetCell(New,"LName", rs_Search.LName)>
	  <cfset QuerySetCell(New,"Address1", rs_Search.Address1)>
	  <cfset QuerySetCell(New,"City", rs_Search.City)>
	  <cfset QuerySetCell(New,"State", rs_Search.State)>
	  <cfset QuerySetCell(New,"Zip", rs_Search.Zip)>
	  <cfset QuerySetCell(New,"Phone", rs_Search.Phone)>
	  <cfset QuerySetCell(New,"Email", rs_Search.Email)>
	  <cfset QuerySetCell(New,"Estimated_LotSize", rs_Search.Estimated_LotSize)>
  	  <cfset QuerySetCell(New,"LawnTreatment", rs_Search.LawnTreatment)>	
  	  <cfset QuerySetCell(New,"FullAeration", rs_Search.FullAeration)>	
   	  <cfset QuerySetCell(New,"SpotAeration", rs_Search.SpotAeration)>	
	  <cfset QuerySetCell(New,"PestControl", rs_Search.PestControl)>	
	  <cfset QuerySetCell(New,"PestControl", rs_Search.grubControl)>	
	  <cfset QuerySetCell(New,"PestControl", rs_Search.moleControl)>	
   	  <cfset QuerySetCell(New,"PerimeterPestControl", rs_Search.PerimeterPestControl)>
	  <cfset QuerySetCell(New,"fallProgram", rs_Search.fallProgram)>
	  <cfset QuerySetCell(New,"sourceCode", rs_Search.sourceCode)>
	  <cfset QuerySetCell(New,"HeardAboutHL", rs_Search.HeardAboutHL)>
	  <cfset QuerySetCell(New,"Redirect", rs_Search.URLRedirect)>
	  <cfif rs_Search.IsLead IS 1>
	  	<cfset QuerySetCell(New,"LeadPurchase", "Lead")>
	  <cfelseif rs_Search.IsPurchase IS 1>
	  	<cfset QuerySetCell(New,"LeadPurchase", "Purchase")>
	  <cfelse>
	  	<cfset QuerySetCell(New,"LeadPurchase", "")>
	  </cfif>
	  <cfset QuerySetCell(New,"Comments", rs_Search.Comments)>
      <cfset QuerySetCell(New,"Contacted", variables.Contacted)>
	  <cfset QuerySetCell(New,"DateTimeStamp", dateFormat(rs_Search.DateTimeStamp,"mm/dd/yyyy"))>
	</cfloop> 
 </cfoutput>
 
 <CFHEADER NAME="content-disposition" VALUE="attachment; filename=Estimates_#DateFormat(Now(),'ddmmyy')#.xls">
<cfcontent type="application/vnd.ms-excel">

<table border="1">
<tr>
	<td>First Name</td>
	<td>Last Name</td>
	<td>Street Address</td>
	<td>City</td>
	<td>State</td>
	<td>Zip Code</td>
	<td>Phone Number</td>
	<td>E-mail</td>
	<td>Estimated Lot Size</td>
	<td>Lawn Treatment</td>
	<td>Aeration Full</td>
	<td>Aeration Spot</td>
	<td>Pest Control</td>
	<td>Grub Guard</td>
	<td>Mole Control</td>
	<td>Perimeter Pest Control</td>
	<td>Fall Program</td>
	<td>Source Code</td>
	<td>Where did you hear about us?</td>
	<td>Redirect</td>
	<td>Lead/Purchase</td>
	<td>Comments</td>
	<td>Contacted</td>
	<td>Date Requested</td>
</tr>
<cfloop query="New">
<cfoutput>
<tr>
<td>#FName#</td>
<td>#LName#</td>
<td>#Address1#</td>
<td>#City#</td>
<td>#State#</td>
<td>#Zip#</td>
<td>#Phone#</td>
<td>#Email#</td>
<td>#Estimated_LotSize#</td>
<td>#LawnTreatment#</td>
<td>#FullAeration#</td>
<td>#SpotAeration#</td>
<td>#PestControl#</td>
<td>#grubControl#</td>
<td>#moleControl#</td>
<td>#PerimeterPestControl#</td>
<td>#fallProgram#</td>
<td>#sourceCode#</td>
<td>#HeardAboutHL#</td>
<td>#Redirect#</td>
<td>#LeadPurchase#</td>
<td>#Comments#</td>
<td>#Contacted#</td>
<td>#DateTimeStamp#</td>
</tr>
</cfoutput>
</cfloop>
</table>
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.