![Antiguo](http://static.forosdelweb.com/fdwtheme/images/statusicon/post_old.gif)
13/05/2004, 21:38
|
![Avatar de sism82](http://static.forosdelweb.com/customavatars/avatar44724_1.gif) | | | Fecha de Ingreso: octubre-2003 Ubicación: Guadalajara
Mensajes: 865
Antigüedad: 21 años, 3 meses Puntos: 1 | |
si te refieres a generar un reporte que pueda ser exportado a excel. Actualmente excel permite enviarle html, digamos una tabla html donde se contengan los resultados y la desplegara. Por ejemplo:
<?php
$sqlEmpleados = "SELECT * FROM empleados";
$rssEmpleados = mysql_query($sqlEmpleados,$con);
ob_start();
?>
<table>
<tr>
<td>Nombre del Empleado</td>
<td>Teléfono</td>
</tr>
<?php
while($empleado = mysql_fetch_object($rssEmpleados))
{
?>
<tr>
<td><?php echo $empleado->nombre; ?></td>
<td><?php echo $empleado->telefono; ?></td>
</tr>
<?php
}//fin while
?>
</table>
<?php
$excelFileName = "reporte_empleados.xls";
$excelFile = fopen($excelFileName,"w");
$htmlTabla = ob_get_contents();
fwrite($excelFile,$htmlTabla);
?>
<a href="<?php echo $excelFileName; ?>" target="_blank">Reporte en Excel</a>
guardar el contenido html pertintente en el búffer con ob_start() es una opción, la otra es ir separando cada celda de tabla con una tabulación y de igual forma excel lo lee.
Saludos |