Link to home
Start Free TrialLog in
Avatar of madeline448
madeline448

asked on

save as CSV format

Hey guys,

Anyone have an idea on how to create a CSV file and have the user download it (save as file). I've done it in php, and I guess its also possible in ASP.

I've visited this thread, (https://www.experts-exchange.com/questions/20349406/Creating-a-CSV-file.html) and it just showed on how to create the csv. My question is, is it possible to have users see the save as/download this file when user clicks Download button? If it is, anyone can show me a sample code...
Avatar of Michel Sakr
Michel Sakr
Flag of Canada image

Hi madeline448,
something like:
<%
Response.ContentType = "application/vnd.ms-excel"

Response.AddHeader "Content-disposition", "attachment; filename=report" & Day(Date) & Month(Date) & 
Year(Date) & ".xls"

' contents here...
%>

----
The "attachment" attribute is a directive to the browser to save, not to show, the document. It doesn't
work with IE 4.01 as this browser has a bug with it (it's a RFC though). If you want the browser to
open the document by default, use "inline" instead.


http://support.microsoft.com/support/kb/articles/Q260/5/19.ASP

Cheers!
Michel
MCAD, MCSA, MCDBA
ASKER CERTIFIED SOLUTION
Avatar of Michel Sakr
Michel Sakr
Flag of Canada image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
So humble Moderator.. any news.. your feedback should be @ the speed of lightening :o)

Cheers!
Michel
MCAD, MCSA, MCDBA
Avatar of madeline448
madeline448

ASKER

Silvers5,

still working on your codes...hope that i was doing it right, my mind is not in sync...**bump bump bump
Silvers5,
question...is the strFileName a mappath of virtual path?
>strFileName a mappath of virtual path?
whatever you like.. it can be both
it can be
Response.BinaryWrite objBinaryFile.GetFileBytes(CStr(server.mappath(strFileName)))
to get the physical path..
Hi,

Everythings working fine now. Thanks Silvers.

BTW, I found this link somewhere, could be useful too http://www.xefteri.com/articles/may082002/default.aspx