Saving as csv file

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • mehj123
    New Member
    • Aug 2007
    • 55

    Saving as csv file

    Hi,

    I want to save data in a html table in the .csv format. I am able to save the data in a normal text file by using the command
    Code:
    <button onclick="javascript:document.execCommand('SaveAs','1','FraudReport.txt')">Click to save</Button>
    I want to save the same in .csv format.
    Thanks
  • gits
    Recognized Expert Moderator Expert
    • May 2007
    • 5390

    #2
    hi ...

    execCommand is IE specific and will not work with other browsers ... probably you should do that on serverside ...

    kind regards

    Comment

    • mehj123
      New Member
      • Aug 2007
      • 55

      #3
      Originally posted by gits
      hi ...

      execCommand is IE specific and will not work with other browsers ... probably you should do that on serverside ...

      kind regards
      Oh.. so is there any other way to do this?

      Comment

      • pronerd
        Recognized Expert Contributor
        • Nov 2006
        • 392

        #4
        Originally posted by mehj123
        Oh.. so is there any other way to do this?
        Yes, just not with JavaScript. Most browsers will not let you save files, or directly write to disk via JavaScript logic. It is too much of a security risk. IE will let you do it if you lower the browsers security settings to a point that is not safe for general use.

        The best way to do this would be to use a server side language (PHP, Python, C#, ASP.NET, etc.) to create the file, and have the user save the file though their browser.

        Comment

        • mehj123
          New Member
          • Aug 2007
          • 55

          #5
          Thanks a lot ... I am now trying to do it in server side.. :)

          Comment

          Working...