Results 1 to 5 of 5
  1. #1
    beginner is offline new member
    Join Date
    Dec 2009
    Posts
    7

    Default export reports as .csv file in browsers computer

    Hi all,

    I had generated backend reports as tables. now i have to give the option to export that table. Already im using manual code to export data as .csv file . But the pbm is, this report is getting stored in server itself ( same folder where the code is). but i need some code to save file in client (user ) mechine.
    some one plz help.

  2. #2
    DavidAllen's Avatar
    DavidAllen is offline Premium Member
    Join Date
    Jan 2007
    Location
    Amersham
    Posts
    511

    Default

    Hi
    It is actually surprisingly easy to do

    PHP Code:
    header"Content-type: application/octet-stream");
    header"Content-disposition:  attachment; filename=My.csv"); 
    echo out the above and then just echo the csv file contents and hey presto - one csv (called My.csv) will be downloaded to the users computer


    Hope this helps
    David Allen - www.serina.co.uk

  3. #3
    beginner is offline new member
    Join Date
    Dec 2009
    Posts
    7

    Default

    Ya its woking fine. thanks for help...
    But, one more problem,is


    Generally, the popup will ask us three option ==> open, save, cancel.
    But this popup asks ==> Find, save, Cancel

    Why ? Can u explain me plz !

  4. #4
    DavidAllen's Avatar
    DavidAllen is offline Premium Member
    Join Date
    Jan 2007
    Location
    Amersham
    Posts
    511

    Default

    Quote Originally Posted by beginner View Post
    Generally, the popup will ask us three option ==> open, save, cancel.
    But this popup asks ==> Find, save, Cancel

    Why ? Can u explain me plz !
    Think it's because there is no program associated with .csv files on your computer. if you set .csv to always open with Excel or notepad (or whatever program you want) then the find option will change to 'Open'

    Regards
    David Allen - www.serina.co.uk

  5. #5
    beginner is offline new member
    Join Date
    Dec 2009
    Posts
    7

    Default

    Great, thanks for help

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •