Important alert: (current site time 7/29/2014 12:15:42 AM EDT)
 

article

Query to MS Excel

Email
Submitted on: 8/5/2008 4:25:48 PM
By: Tim Garver  
Level: Beginner
User Rating: By 5 Users
Compatibility: Cold Fusion MX
Views: 65566
author picture
(About the author)
 
     Output excel file easy with ColdFusion MX. Hi Many years ago i wrote an article here to create an excel CSV file with ColdFusion. I wanted to update this with the newer easier way to accomplish the same goal. have a search page with an output type drop box called "otype" values("web","xls","prt") Write out your page in an HTML table with the columns you want in excel. Then put an IF statement around your table or simply at the bottom of the page with links to the same page with the otype or a form that submits to the same page with the otype var. then use this code:

 
 
Terms of Agreement:   
By using this article, you agree to the following terms...   
  1. You may use this article in your own programs (and may compile it into a program and distribute it in compiled format for languages that allow it) freely and with no charge.
  2. You MAY NOT redistribute this article (for example to a web site) without written permission from the original author. Failure to do so is a violation of copyright laws.   
  3. You may link to this article from another website, but ONLY if it is not wrapped in a frame. 
  4. You will abide by any additional copyright restrictions which the author may have placed in the article or article's description.
				<cfif #form.otype# EQ "xls">
	<cfheader 
	 name="Content-Type" 
	 value="application/msexcel">
	
	<cfheader 
	 name="Content-Disposition" 
	 value="attachment; filename=MyReport.xls">
 <cfelseif #form.otype# EQ "prt">
	<cfheader 
	 name="Content-Type" 
	 value="application/msword">
	
	<cfheader 
	 name="Content-Disposition" 
	 value="attachment; filename=MyReport.doc">
</cfif>
Thats it, very simple and when the link is clicked or form is submited, the user will be asked to download the Excel file.


Other 11 submission(s) by this author

 


Report Bad Submission
Use this form to tell us if this entry should be deleted (i.e contains no code, is a virus, etc.).
This submission should be removed because:

Your Vote

What do you think of this article (in the Beginner category)?
(The article with your highest vote will win this month's coding contest!)
Excellent  Good  Average  Below Average  Poor (See voting log ...)
 

Other User Comments

7/24/2008 5:22:10 AMquery to excell

gf
(If this comment was disrespectful, please report it.)

 
9/3/2008 3:43:11 PMomar

ingreso nuevo
(If this comment was disrespectful, please report it.)

 
11/8/2008 12:08:22 AMardhi

penting bgt niy.
(If this comment was disrespectful, please report it.)

 
2/11/2009 10:13:21 PMparesh

it is good
(If this comment was disrespectful, please report it.)

 
2/23/2009 11:22:16 PMsaeba

can give me same matery

(If this comment was disrespectful, please report it.)

 
8/10/2009 11:35:53 PMaaa

ffgefge
(If this comment was disrespectful, please report it.)

 
9/21/2010 6:46:49 AMHari

Good Artcle

(If this comment was disrespectful, please report it.)

 
12/27/2010 9:05:58 AMpilipara.dakajaska

good
(If this comment was disrespectful, please report it.)

 

Add Your Feedback
Your feedback will be posted below and an email sent to the author. Please remember that the author was kind enough to share this with you, so any criticisms must be stated politely, or they will be deleted. (For feedback not related to this particular article, please click here instead.)
 

To post feedback, first please login.