Re: Pasar a excel
| From: | Jonathan Lara | Date: | Thu, 12 Jun 2003 19:09:38 +0000 |
| Subject: | Re: Pasar a excel | ||
| References: | 1 | Groups: | php.general.es |
| Request: | Send a blank email to general-es+get-37315@lists.php.net to get a copy of this message | ||
O metes los datos separados por comas* y lo tiras al download, y te
apareceran en sus casillas
respectivas segun el orden dado
*= si utilizan esta opcion, office 97 y 2000 separenlo con comas(,), si
utilizan office xp separenlo por punto y coma (;)
adjunto un script muy util para tablas de muchos elementos.
----- Original Message -----
From: "Manuel A. Garcia" <mgarcia@rimisp.cl>
To: <lista@phpes.com>
Sent: Thursday, June 12, 2003 1:20 PM
Subject: [PHP-ES] Pasar a excel
> Hola Liter@s
>
> Tengo un problema :(
>
> Tengo q leer unos datos de la DB y pasarlos a un excel (xls).
> Alguien ha echo algo parecido??? o saben de donde puedo sacar info???
>
> Gracias
> M. García.
>
>
>
>
> ---------------------------------------------------------------------
> Archivo On-line: http://www.phpes.com/
> via news: news://news.phpes.com/
> Manual PHP en español: http://www.php.net/manual/es/
> Para dar de baja la suscripción, mande un mensaje a:
> lista-unsubscribe@phpes.com
>
>
$separador = ","; // ";" para compatibilidad con office xp $result = mysql_query("SELECT * FROM $id"); while($row = mysql_fetch_array($result)) { $l = sizeof($row); $c = 0; while ($c < $l) { $csv_output .= $row[$c] . "$separador "; $c++; } $csv_output .= "\n"; } $now = gmdate('D, d M Y H:i:s') . ' GMT'; $mime_type = 'text/x-csv'; header('Content-Type: ' . $mime_type); header('Expires: ' . $now); $browser = strtolower($_SERVER["HTTP_USER_AGENT"]); if (strstr($browser,"MSIE")) { header("Content-Disposition: inline; filename=" . $id . "-" . date("d-m-Y").".csv"); header('Cache-Control: must-revalidate, post-check=0, pre-check=0'); header('Pragma: public'); } else { header("Content-Disposition: attachment;filename=" . $id . "-" . date("d-m-Y").".csv"); header('Pragma: no-cache'); } print $csv_output; exit;
$separador = ","; // ";" para compatibilidad con office xp $result = mysql_query("SELECT * FROM $id"); while($row = mysql_fetch_array($result)) { $l = sizeof($row); $c = 0; while ($c < $l) { $csv_output .= $row[$c] . "$separador "; $c++; } $csv_output .= "\n"; } $now = gmdate('D, d M Y H:i:s') . ' GMT'; $mime_type = 'text/x-csv'; header('Content-Type: ' . $mime_type); header('Expires: ' . $now); $browser = strtolower($_SERVER["HTTP_USER_AGENT"]); if (strstr($browser,"MSIE")) { header("Content-Disposition: inline; filename=" . $id . "-" . date("d-m-Y").".csv"); header('Cache-Control: must-revalidate, post-check=0, pre-check=0'); header('Pragma: public'); } else { header("Content-Disposition: attachment;filename=" . $id . "-" . date("d-m-Y").".csv"); header('Pragma: no-cache'); } print $csv_output; exit;