lyrix1999
asked on
how to create a excel/csv file on the fly?
Hello, I did my search around here and find Shooksm's code.
<cfheader name="content-disposition" value="attachment;filename =#Left(Cre ateUUID(), 8)#.html">
<cfcontent type="application/octet-st ream">
<html>
<head>
<title>Your Custom Query</title>
</head>
<body>
<cfoutput>
<table border="1" width="100%"><cfloop index="i" from="0" to="95" step="5">
<tr>
<td>#i+1#</td>
<td>#i+2#</td>
<td>#i+3#</td>
<td>#i+4#</td>
<td>#i+5#</td>
</tr></cfloop>
</table>
</cfoutput>
</body>
</html>
But after I copied and pasted into a blank cfm file, when I call it from browser. it returns the table in the browser though I was expecting a download box pop up?
I am using CF4.5 by the way, could that be the reason?
Also it seems the <cfsavecontent> is introduced in 5.0. What should I do to get the equvilent?
I am trying to develop a page to show a table report and if clients want, they can click a button/link to download it into excel. I hope there is a way I don't need to write the report twice.
Thanks,
lyrix
<cfheader name="content-disposition"
<cfcontent type="application/octet-st
<html>
<head>
<title>Your Custom Query</title>
</head>
<body>
<cfoutput>
<table border="1" width="100%"><cfloop index="i" from="0" to="95" step="5">
<tr>
<td>#i+1#</td>
<td>#i+2#</td>
<td>#i+3#</td>
<td>#i+4#</td>
<td>#i+5#</td>
</tr></cfloop>
</table>
</cfoutput>
</body>
</html>
But after I copied and pasted into a blank cfm file, when I call it from browser. it returns the table in the browser though I was expecting a download box pop up?
I am using CF4.5 by the way, could that be the reason?
Also it seems the <cfsavecontent> is introduced in 5.0. What should I do to get the equvilent?
I am trying to develop a page to show a table report and if clients want, they can click a button/link to download it into excel. I hope there is a way I don't need to write the report twice.
Thanks,
lyrix
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Unfortunately I am not familiar with CF 4.5 so I am not sure what would work in place of <cfsavecontent>
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Hi, Shooksm, thanks for your kind help. I don't know how to split the points otherwise I must give you some. Even though I just figure out a way around it, your method is also cool.
I will request that a moderator split the points between us.
ASKER
Do you happen to know the answer to the other question? How do I use something else in 4.5 for <cfsavecontent> so I don't need to write twice or the server won't need to run twice for the online report and downloadable report?
Thanks,
lyrix