Results 1 to 5 of 5

Thread: export to excel

  1. #1

    Angry export to excel

    Hi guys,

    I have a script to export data from mysql to excel, and it runs ok but leaves a bank screen. God knows where the export is...

    so I tried this, but get some weird errors...anyone know why, or have a better export script?

    <?php
    header("Content-type: application/x-msdownload");
    header("Content-Disposition: attachment; filename=extraction.xls");
    header("Pragma: no-cache");
    header("Expires: 0");
    print "$headern$data";
    ?>

  2. #2
    Join Date
    Apr 2003
    Location
    UK
    Posts
    2,560
    does it have to be web based?

  3. #3
    Originally posted by Slidey
    does it have to be web based?
    what did you have in mind? (bit new to this you see)

  4. #4
    Join Date
    Apr 2004
    Location
    Port St Lucie, FL
    Posts
    117
    Probably the easiest way to do it would be to export to a CSV file (which Excel will then use).

    Try this instead..

    PHP Code:

    <?php

    // We'll be outputting a CSV
    header('Content-type: text/comma-separated-values');

    // Name it extraction.csv
    header('Content-Disposition: attachment; filename="extraction.csv"');

    echo 
    "$headern$data"

    ?>
    PM me if you need any more help.
    Paul Embry
    Knight Software and Web Design
    [email protected]
    Quality PHP Web Programming for Reasonable Prices

  5. #5
    Join Date
    Apr 2003
    Location
    UK
    Posts
    2,560
    i use perl and the spreadsheet::writeexcel perl module a LOT to do thsi sorta thing. it writes in the native excel format, and you can do all sortsa formatting etc. i usually take stuff from an oracle database but it'll be exactly the same idea with mysql as i use the DBI module..

    all *nix commandline based

Posting Permissions

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