> I am looking for the easiest way to export data to an excel file. Is
> the eaiest way to use PHP's file handling functions?

I assume you want to delivery the execl file to a web user.
Then there is no need to write the data to disk, you can
generate the whole thing on the fly while you deliver it to the
user. Here is a basic description on how:

1) Create a PHP document to generate the execl file and make
   sure the script produces HTTP headers telling the user agent
   that it is receiving an excel document. Start the script

      header ("Content-type: application/");
      header ("Content-Disposition: attachment" );

   The content disposition header says that the execl file is
   to be stored on disk. 

2) Generate the spreadsheet data as a list of newline separated
   rows with tab separated fields:

   echo "field1\tfield2\t...\n";

3) Set up a link to the new PHP document. When a user clicks on
   that link, he will be prompted by his user agent on where to
   save the excel file.


Geir Pedersen

PHP Database Mailing List (
To unsubscribe, visit:

Reply via email to