Ver Mensaje Individual
  #1 (permalink)  
Antiguo 02/05/2013, 19:12
mariomb19
 
Fecha de Ingreso: mayo-2012
Ubicación: Caracas
Mensajes: 53
Antigüedad: 12 años, 10 meses
Puntos: 1
Pregunta No me impime el codigo en el excel

Buenas estoy en proceso de aprendizaje tengo una tarea que estoy terminando pero no ayo como imprimir los datos en la base de datos a un archivo .XLS, que se buscan por fecha de inicio y fecha fin, el query corre bien solo y el excel se genera bien si selección de fecha, pero viene vacío, cuando le pongo la fecha no me dice nada


[

Código HTML:
Ver original
  1. <form action="excel.php" id="form1" name="form1" method="post" >
  2.             <!-- CONTENT -->
  3.             <div id="content" style="width: 915px;">
  4.             <h1>Modulo de Generación de Estadística</h1>       
  5.                     <strong>Fecha de inicio:</strong>
  6.                         <input type="text" name="fecha_inicio" id="fecha_inicio"
  7.                         onClick="ShowCalendario(event)" size="10">  
  8.                     <strong>Fecha Fin:</strong>
  9.                     <input ="text" name="fecha_fin" id="fecha_fin"
  10.                         onClick="ShowCalendario(event)" size="10">
  11.                     <p></p>
  12.                     <p></p>
  13.                    
  14.                     <input type="submit" name="Buscar"id="Buscar" value="Buscar" >
  15.                        
  16.             </div>
  17.             <!-- / content -->
  18.             </form>


Código PHP:
Ver original
  1. <?php
  2.    
  3. //Traemos las librerias necesarias
  4. require_once("../Classes/PHPExcel.php");
  5. require_once("../Classes/PHPExcel/Writer/Excel2007.php");
  6.  
  7. //objeto de PHP Excel
  8. $objPHPExcel = new PHPExcel();
  9.  
  10. //algunos datos sobre autoría
  11. $objPHPExcel->getProperties()->setCreator("Mario Moreno");
  12. $objPHPExcel->getProperties()->setLastModifiedBy("Mario Moreno");
  13. $objPHPExcel->getProperties()->setTitle("Office 2007 XLSX Reporte de Clientes");
  14. $objPHPExcel->getProperties()->setSubject("Office 2007 XLSX Reporte de Clientes");
  15. $objPHPExcel->getProperties()->setDescription("Reporte de Clientes para Office 2007 XLSX, Usando PHPExcel.");
  16.  
  17.  
  18. //Trabajamos con la hoja activa principal
  19. $objPHPExcel->setActiveSheetIndex(0);
  20.  
  21. $fecha_inicio= $_REQUEST['fecha_inicio'];
  22. $fecha_fin= $_REQUEST['fecha_fin'];
  23.  
  24.     if ($fecha_inicio=='0000-00-00') {
  25.         //echo $fecha_inicio;
  26.         }   else {
  27.         $fecha_inicio=date("Y-m-d",strtotime($fecha_inicio));
  28.         //echo $fecha_inicio;
  29.     }
  30.     if ($fecha_fin=='0000-00-00') {
  31.         //echo $fecha_fin;
  32.         }   else {
  33.         $fecha_fin=date("Y-m-d",strtotime($fecha_fin));
  34.         //echo $fecha_fin;
  35.     }  
  36.  
  37.     include "../PHP/conexion.php";
  38.     $registros=mysql_query("SELECT `cod_dea` , `fecha_inicio` , `fecha_fin` , `entregas_2do` , `entregas_3ro` ,
  39.     `entregas_4to` , `entregas_5to` , `entregas_6to` , `total_entregas` , `direccion` , `plantel` , `estado` ,
  40.     `municipio` , `director` , `tlf_director` , `lugar_entrega`
  41.     FROM `cronograma_temp`
  42.     WHERE `fecha_inicio` >= '$fecha_inicio' AND `fecha_fin` <= '$fecha_fin'
  43.     ORDER BY `fecha_inicio`",$conexion)
  44.    or die("Problemas en el select:".mysql_error());
  45.  
  46.  
  47. //iteramos para los resultados
  48.     while($reg=mysql_fetch_array($registros)) {
  49.         $objPHPExcel->getActiveSheet()->SetCellValue("A".$i,$reg["cod_dea"]);
  50.         $objPHPExcel->getActiveSheet()->SetCellValue("B".$i,$reg["fecha_inicio"]);
  51.         $objPHPExcel->getActiveSheet()->setCellValue("C".$i,$reg["fecha_fin"]);
  52.         $objPHPExcel->getActiveSheet()->setCellValue("D".$i,$reg["entregas_2do"]);
  53.     }
  54.  
  55.  
  56. mysql_close($conexion);
  57.  
  58. //Titulo del libro y seguridad
  59. $objPHPExcel->getActiveSheet()->setTitle('Reporte');
  60. $objPHPExcel->getSecurity()->setLockWindows(true);
  61. $objPHPExcel->getSecurity()->setLockStructure(true);
  62.  
  63.  
  64. // Se modifican los encabezados del HTTP para indicar que se envia un archivo de Excel.
  65. header('Content-Type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet');
  66. header('Content-Disposition: attachment;filename="reporteClientes.xlsx"');
  67. header('Cache-Control: max-age=0');
  68. $objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel2007');
  69. $objWriter->save('php://output');
  70.  
  71. ?>