Ver Mensaje Individual
  #4 (permalink)  
Antiguo 14/09/2011, 12:14
matt_1985
 
Fecha de Ingreso: enero-2011
Ubicación: /root
Mensajes: 530
Antigüedad: 13 años, 3 meses
Puntos: 61
Respuesta: problemas al exportar a excel

edito , resolvi mi problema eran las comillas dejo el script por si alguien tiene el mismo problema .

Código PHP:
Ver original
  1. <?php
  2. require_once("../conexion/conexion.php");
  3.  
  4. $buscar=$_GET['palabra'];
  5.  
  6. header('Pragma: public');
  7. header('Expires: Sat, 26 Jul 1997 05:00:00 GMT'); // Date in the past    
  8. header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT');
  9. header('Cache-Control: no-store, no-cache, must-revalidate'); // HTTP/1.1
  10. header('Cache-Control: pre-check=0, post-check=0, max-age=0'); // HTTP/1.1
  11. header('Pragma: no-cache');
  12. header('Expires: 0');
  13. header('Content-Transfer-Encoding: none');
  14. header('Content-Type: application/vnd.ms-excel'); // This should work for IE & Opera
  15. header('Content-type: application/x-msexcel'); // This should work for the rest
  16. header('Content-Disposition: attachment; filename="Informe.xls"'); 
  17.  
  18.  
  19.     $sql = "SELECT unifica_proyectos.id,
  20.                    unifica_proyectos.nombreencuesta,
  21.                   unifica_proyectos.fecha,
  22.                    unifica_proyectos.rut,
  23.                    unifica_proyectos.nombreevaluador,
  24.                    unifica_proyectos.idregion,
  25.                    unifica_proyectos.coordinador,
  26.                    unifica_proyectos.mail,regiones.idregion,
  27.                   regiones.region
  28.             FROM unifica_proyectos INNER JOIN regiones ON unifica_proyectos.idregion = regiones.idregion
  29.             WHERE unifica_proyectos.fecha ='".$buscar."'";
  30.  
  31.     $resultado=mysql_query($sql,$link)or die(mysql_error());
  32.         while($row = mysql_fetch_array($resultado)) {
  33.        
  34.         $nombreencuesta=utf8_encode($row['nombreencuesta']);
  35.         $fecha=$row['fecha'];  
  36.         $fecha=date("d-m-Y",strtotime($fecha));
  37.         $rut=$row['rut'];
  38.         $nombreevaluador=utf8_encode($row['nombreevaluador']);
  39.         $region=utf8_encode($row['region']);
  40.         $coordinador=utf8_encode($row['coordinador']);
  41.         $mail=utf8_encode($row['mail']);
  42.            
  43.        
  44. echo "<table xmlns:o='urn:schemas-microsoft-com:office:office' xmlns:x='urn:schemas-microsoft-com:office:excel' xmlns='http://www.w3.org/TR/REC-html40'>
  45.   <tr>
  46.       <td>$nombreencuesta</td>
  47.        <td>$fecha</td>
  48.        <td>$rut</td>
  49.        <td>$nombreevaluador</td>
  50.        <td>$region</td>
  51.        <td>$coordinador</td>
  52.        <td>$mail</td>
  53.   </tr>
  54. </table>";
  55. }
  56. ?>

saludos

Última edición por matt_1985; 14/09/2011 a las 12:27