Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 280
  • Last Modified:

Need to create a .CSV file from ASP...

I want the user to click on a link that is of file type .csv, so that Excel or whatever program they have registered to read comma seperated values gets invoked.  I need ASP to create this file.  But a .CSV file won't get executed as ASP.  So basically how can I get either an ASP file passed back as .CSV, or a .CSV file to be executed as ASP code???

Thank you,
David
0
dpinkus
Asked:
dpinkus
  • 2
  • 2
1 Solution
 
MasseyMCommented:
Can you be more specific?  Can you post what the CSV file will look like?  What will create the CSV file?
0
 
dpinkusAuthor Commented:
A CSV file looks like this:
"value1","value2","value3", etc.
They can be opened from any application that supports this format, generally Excel.  
For an example, go to:  http://quote.yahoo.com/q?s=YHOO&d=t
Then on the bottom click on "Download Spreadsheet Format".  Depending
on how you are configured, either Excel will be launched (sometimes within
your browser) or you will be prompted to save this file to disk.  
I would like to use an ASP script to create the file, but I don't know how
to send it back as a .csv file instead of an html document...

0
 
MasseyMCommented:
YOu would create the file on the server using what ever you will be using (a program or your scipt) - save it as .csv and then in your ASP script, use this:

response.redirect "physical location of .csv file"

This will send just the csv file to the browser.
0
 
dpinkusAuthor Commented:
Perhaps I didn't phrase my question correctly.  I do not want to physically write a file, I want to execute an ASP script that returns a stream of data back to the browser, but tells the browser that it is a .csv file.  I solved this by putting the following at the beginning of my ASP script:
<%
Response.ContentType = "application/vnd.ms-excel"
%>

This did cause the desired behaviour, of launching their EXCEL application to view the file.  I suppose there is a MIME combination that I can use above for CSV, but I do not know what it is...
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now