SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    gimme the uuuuuuuuuuu duuudie's Avatar
    Join Date
    Feb 2004
    Location
    Switzerland
    Posts
    2,253
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    db to excel: is that possible? how?

    Hey

    Is that possible to convert results of a db search as an .xls document?

    If yes, how? Do I need some extension?

    Thanks in advance

  2. #2
    SitePoint Addict Chillijam's Avatar
    Join Date
    Nov 2003
    Location
    England
    Posts
    293
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    For recent versions of excel, do the following...

    1) Set the content type header to application/vnd.ms-excel
    2) Set any other headers to stop caching

    PHP Code:
     header("Content-type: application/vnd.ms-excel");
     
    header("Content-Disposition: attachment; filename=$filename");
     
    header("Expires: 0");
     
    header("Cache-Control: must-revalidate, post-check=0,pre-check=0");
     
    header("Pragma: public"); 
    3) output your data as an html table. Don't include anything that is not an html table. Your first line of content should be your <table> tag, your last should be the </table> closing tag, and all content should be valid table data.

    That's it.

    If you want to do things like multiple sheets, you'll probably need the PEAR Excel writer module.

    HTH
    Your mind is like a parachute. It works best when open.
    (HH The Dalai Lama)

  3. #3
    gimme the uuuuuuuuuuu duuudie's Avatar
    Join Date
    Feb 2004
    Location
    Switzerland
    Posts
    2,253
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    wow cool!



    thanks for the reply.

  4. #4
    Now with customized title Jump's Avatar
    Join Date
    Sep 2002
    Location
    The Restaurant at The End of The Universe
    Posts
    1,423
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hey! That's pretty cool.

  5. #5
    SitePoint Member
    Join Date
    Nov 2004
    Location
    India
    Posts
    9
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    hey thats preety cool one more thing which you can do also is as u creating a rs of it

    you can try saving the recordset, i think so it allows to save it

    just check this out


Bookmarks

Posting Permissions

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