Re: exporting data to excel

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hello all
 
I am also needing to do this - I got the xcel ss to generate but it wont tab to the next cell in xcel...

Here's what I've tried so far:

********************************
<?php
  while ($row = mysql_fetch_assoc($res)) {  
  echo $row[first]  . "\t"  . $row[last] . "\n";
//  echo $row[first]  . ","  . $row[last] . "\n";
//  echo "$row[first],$row[last]\n";
//  echo "$row[first]\t$row[last]\t\n";
//  echo $row[first] . "," . $row[last];
  }
  ?>

*******************************

But I get all the fields in one cell on each of these tries... 

Thanks

>>> Geir Pedersen - Activio AS <geirp@xxxxxxxxxxx> 03/24/04 08:04PM >>>

Matthew,

> 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
   with:

      header ("Content-type: application/vnd.ms-excel");
      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
http://www.activio.com/ 

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php 

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[Index of Archives]     [PHP Home]     [PHP Users]     [Postgresql Discussion]     [Kernel Newbies]     [Postgresql]     [Yosemite News]

  Powered by Linux