Ver Mensaje Individual
  #1 (permalink)  
Antiguo 30/01/2014, 06:21
JorgeQuirino
 
Fecha de Ingreso: enero-2014
Mensajes: 111
Antigüedad: 10 años, 3 meses
Puntos: 1
Problemas al exportar tabla completa desde mysql a excel

tengo problemas al exportar la tabla de mysql, me extrae serca de 90 datos, pero dentro de la tabla ahi serca de 170, cual sera el problema, aqui esta el codigo
Saludos y gracias

Código PHP:
Ver original
  1. <html>
  2. <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
  3.  <meta name="viewport" content="width=device-width">
  4.       <link href="bootstrap/css/bootstrap.min.css" rel="stylesheet" >
  5. <body>
  6.  
  7. <?php
  8. header("Content-Type: text/html;charset=utf-8");
  9. //Variables de conexion
  10. $dbhost = "localhost";
  11. $dbuser = "root";
  12. $dbpassword = "";
  13. $dbname = "automatizacion";
  14. header('Content-Type: text/html; UTF-8');
  15.  
  16. $db = mysql_connect($dbhost, $dbuser, $dbpassword) or die("Connection Error: " . mysql_error()); mysql_select_db($dbname) or die("Error al conectar a la base de datos.");
  17. mysql_query("SET NAMES 'utf8'");
  18. //MOSTRAMOS TODAS LAS TABLAS
  19. $sql = "SELECT * FROM `respaldoSeguimientoVulnerabilidad` ";
  20.    
  21. $result = mysql_query( $sql ) or die("No se puede ejecutar la consulta: ".mysql_error());
  22. $numero = 0;
  23.  
  24.  
  25. echo "<table border='1' width='' heigth=''>";
  26.  
  27.     echo "<tr><td colspan=20><center>TABLA DE Comparativo</center></td>
  28.     </tr>";
  29.    
  30. echo "  <tr>
  31.      <td>Id</td>
  32.      <td>Origen</td>
  33.      <td>Sistema Afectado /IP</td>
  34.      <td>Código</td>
  35.      <td>Nombre</td>
  36.      <td>Detalle debilidad</td>
  37.      <td>Impacto</td>
  38.      <td>Recomendación</td>
  39.      <td>Tipo (APP-SInfraestructura)</td>
  40.      <td>Criticidad (A-M-B)</td>
  41.      <td>Exposición</td>
  42.      <td>Área</td>
  43.      <td>Responsable</td>
  44.      <td>Fecha Inicio</td>
  45.      <td>Periodo</td>
  46.      <td>Plazo(semanas)</td>
  47.      <td>Fecha de Cierre</td>
  48.      <td>Estado</td>
  49.      <td>Acciones</td>
  50.      <td>Comentario</td>
  51.     <td>Nuevo Estado</td>
  52.    
  53.     </tr>";
  54.    
  55.    
  56. //MOSTRAMOS LA INFORMACION DE LOS CAMPOS
  57. while($Rs2 = mysql_fetch_array($result))
  58.  
  59.  {
  60.  print ('<tr>');
  61.     echo ('<td width="2%">'.$Rs2['ID'].'</td>');
  62.     echo ('<td width=8%">'.$Rs2['Origen'].'</td>');
  63.     echo ('<td width="3%">'.$Rs2['Sistema Afectado / IP'].'</td>');
  64.     echo ('<td width="3%">'.$Rs2['Codigo'].'</td>');
  65.     echo ('<td width="5%">'.$Rs2['Nombre'].'</td>');
  66.     echo ('<td width="1%">'.$Rs2['Detalle debilidad'].'</td>');
  67.     echo ('<td width="3%">'.$Rs2['Impacto'].'</td>');
  68.     echo ('<td width="5%">'.$Rs2['Recomendacion'].'</td>');
  69.     echo ('<td width="5%">'.$Rs2['Tipo (APP-SInfraestrcutura)'].'</td>');
  70.     echo ('<td width="5%">'.$Rs2['Criticidad (A-M-B)'].'</td>');
  71.     echo ('<td width="5%">'.$Rs2['Exposicion'].'</td>');
  72.     echo ('<td width="5%">'.$Rs2['Area'].'</td>');
  73.     echo ('<td width="5%">'.$Rs2['Responsable'].'</td>');
  74.     echo ('<td width="5%">'.$Rs2['Fecha de inicio'].'</td>');
  75.     echo ('<td width="5%">'.$Rs2['Periodo'].'</td>');
  76.     echo ('<td width="5%">'.$Rs2['Plazo (semanas)'].'</td>');
  77.     echo ('<td width="5%">'.$Rs2['Fecha de cierre'].'</td>');
  78.     echo ('<td width="5%">'.$Rs2['Estado'].'</td>');
  79.     echo ('<td width="5%">'.$Rs2['Acciones'].'</td>');
  80.     echo ('<td width="5%">'.$Rs2['Comentarios'].'</td>');
  81.     echo ('<td width="5%">'.$Rs2['NUEVO ESTADO'].'</td>');
  82.     echo ('</tr>');
  83.     $numero++;
  84.    
  85. }
  86. echo "</table>";
  87. header("Content-Type: application/vnd.ms-excel");
  88. header("Expires: 0");
  89. header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
  90. header("content-disposition: attachment;filename=NOMBRE.xls");
  91.  
  92.  
  93. ?>
  94.  
  95. </body>
  96. </html>