downloading csv file from asp page to client browser

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • gauravgeek
    New Member
    • Jun 2007
    • 2

    downloading csv file from asp page to client browser

    Hi,

    I want to create a csv file on the fly and download it on client browser. I have all the content of csv file in a vb script variant variable. I created the csv file using textstream and FSO object.
    I have tried adodb streaming(using ADODB.Stream object) to download but it requires me to save the content in a csv file on the server before I can download it to client browser. This creates additional problem of file cleanup. The file download takes time(probably it spawns a new thread) and an attempt to delete the csv file on the server gives an error.
    So, I want to do it on the fly, without creating a csv file on server.

    Any suggestions and solution would greatly help.
    Thanks,
    Gaurav
  • merseyside
    New Member
    • Mar 2007
    • 48

    #2
    Try this, changing the content type of what the script delivers to the browser from the usual text/html to text/csv and to expect an attachment

    Code:
    response.ContentType = "text/csv"
    response.AddHeader "Content-Disposition", "attachment;filename=""list.csv"""
    reponse.write("a,b,c" & vbCrLF & "1,2,3")

    Comment

    • gauravgeek
      New Member
      • Jun 2007
      • 2

      #3
      Originally posted by merseyside
      Try this, changing the content type of what the script delivers to the browser from the usual text/html to text/csv and to expect an attachment

      Code:
      response.ContentType = "text/csv"
      response.AddHeader "Content-Disposition", "attachment;filename=""list.csv"""
      reponse.write("a,b,c" & vbCrLF & "1,2,3")

      Hi,

      That did work, though a little slowly because the file I am downloading to client is nearly 2.5 mb.

      Thanks a lot anyways,
      Gaurav

      Comment

      Working...