CF Excel Download

Yesterday I needed to make some data from the administrator section available for download so that they could compile some quarterly reports with the data. So the plan was to do some custom programming to output the data into table form so that it could easily be turned into an excel spreadsheet. I know our company has done this before, but I have never done this before. So what better way to learn than to ask a person who has done it before how to do it. Naturally, I immediately went to our lead programmer, Amy, to get some details on how its done. Thankfully, she was able to tell me that it was simple and easy to implement, instead of letting me know that a giant headache would soon ensue. So she went searching for a prime example of this and I wandered back to my desk. After a moment or so, I got an email with the needed code snippet in it. She was right, it didn’t look so bad. Her version was accounting for a wrapper so I had to use it in a slightly different way, but for the most part it was a straight up addition without a lot of fuss. I can only wish that all code additions were as clean cut and easy to do as this was.

Here is the code snippet as I used it:

<CFHEADER NAME=”Content-Disposition” VALUE=”attachment;filename=downloadreport.xls”>
<cfcontent type=”application/”>

<html xmlns:o=”urn:schemas-microsoft-com:office:office” xmlns:x=”urn:schemas-microsoft-com:office:excel” xmlns=“″>
<meta http-equiv=Content-Type content=”text/html; charset=windows-1252″>
<meta name=ProgId content=Excel.Sheet>
<meta name=Generator content=”Microsoft excel”>
//table content all goes here

Now I can’t say that I understand really how it works, but it does. Sometimes just knowing the code to use is fine as long as it works. This is mostly true with simple code that doesn’t need much customization. The same probably doesn’t hold true for more advanced programming applications since any change will require your full understanding of the code to be able to pull it off successfully. For me this is done and was simple, so it’s off to the next task at hand: changes to a Flash presentation from client feedback, ahhhh!