query($consulta); if($resultado->num_rows > 0 ){ date_default_timezone_set('America/Argentina/Buenos_Aires'); if (PHP_SAPI == 'cli') die('Este archivo solo se puede ver desde un navegador web'); $objPHPExcel->getProperties()->setCreator("Supapel") // Nombre del autor ->setLastModifiedBy("Supapel") //Ultimo usuario que lo modificó ->setTitle("Reporte IQR") // Titulo ->setSubject("Reporte INASE") //Asunto ->setDescription("Reporte Eventos") //Descripción ->setKeywords("reporte Eventos") //Etiquetas ->setCategory("Reporte excel"); //Categorias $tituloReporte = "Reporte Eventos"; $titulosColumnas = array('ID', 'Name', 'Code', 'Date','Lat','Lng','Original'); $objPHPExcel->setActiveSheetIndex(0) $objPHPExcel->setActiveSheetIndex(0) ->setCellValue('A1',$tituloReporte) // Titulo del reporte ->setCellValue('A3', $titulosColumnas[0]) //Titulo de las columnas ->setCellValue('B3', $titulosColumnas[1]) ->setCellValue('C3', $titulosColumnas[2]) ->setCellValue('D3', $titulosColumnas[3]) ->setCellValue('E3', $titulosColumnas[4]) ->setCellValue('F3', $titulosColumnas[5]) ->setCellValue('G3', $titulosColumnas[6]); //Se agregan los datos $i = 4; //Numero de fila donde se va a comenzar a rellenar while ($fila = $resultado->fetch_array()) { $objPHPExcel->setActiveSheetIndex(0) ->setCellValue('A'.$i, $fila['ID']) ->setCellValue('B'.$i, $fila['Name']) ->setCellValue('C'.$i, $fila['Code']) ->setCellValue('D'.$i, $fila['Date']) ->setCellValue('E'.$i, $fila['Lat']) ->setCellValue('F'.$i, $fila['Lng']) ->setCellValue('G'.$i, $fila['Original']); $i++; } $estiloTituloReporte = array( 'font' => array( 'name' => 'Verdana', 'bold' => true, 'italic' => false, 'strike' => false, 'size' =>16, 'color' => array( 'rgb' => 'FFFFFF' ) ), 'fill' => array( 'type' => PHPExcel_Style_Fill::FILL_SOLID, 'color' => array( 'argb' => 'FF220835') ), 'borders' => array( 'allborders' => array( 'style' => PHPExcel_Style_Border::BORDER_NONE ) ), 'alignment' => array( 'horizontal' => PHPExcel_Style_Alignment::HORIZONTAL_CENTER, 'vertical' => PHPExcel_Style_Alignment::VERTICAL_CENTER, 'rotation' => 0, 'wrap' => TRUE ) ); $estiloTituloColumnas = array( 'font' => array( 'name' => 'Arial', 'bold' => true, 'color' => array( 'rgb' => 'FFFFFF' ) ), 'fill' => array( 'type' => PHPExcel_Style_Fill::FILL_GRADIENT_LINEAR, 'rotation' => 90, 'startcolor' => array( 'rgb' => 'c47cf2' ), 'endcolor' => array( 'argb' => 'FF431a5d' ) ), 'borders' => array( 'top' => array( 'style' => PHPExcel_Style_Border::BORDER_MEDIUM , 'color' => array( 'rgb' => '143860' ) ), 'bottom' => array( 'style' => PHPExcel_Style_Border::BORDER_MEDIUM , 'color' => array( 'rgb' => '143860' ) ) ), 'alignment' => array( 'horizontal'=> PHPExcel_Style_Alignment::HORIZONTAL_CENTER, 'vertical' => PHPExcel_Style_Alignment::VERTICAL_CENTER, 'wrap' => TRUE ) ); $estiloInformacion = new PHPExcel_Style(); $estiloInformacion->applyFromArray( array( 'font' => array( 'name' => 'Arial', 'color' => array( 'rgb' => '000000' ) ), 'fill' => array( 'type' => PHPExcel_Style_Fill::FILL_SOLID, 'color' => array( 'argb' => 'FFd9b7f4') ), 'borders' => array( 'left' => array( 'style' => PHPExcel_Style_Border::BORDER_THIN , 'color' => array( 'rgb' => '3a2a47' ) ) ) )); $objPHPExcel->getActiveSheet()->getStyle('A1:D1')->applyFromArray($estiloTituloReporte); $objPHPExcel->getActiveSheet()->getStyle('A3:D3')->applyFromArray($estiloTituloColumnas); $objPHPExcel->getActiveSheet()->setSharedStyle($estiloInformacion, "A4:D".($i-1)); for($i = 'A'; $i <= 'D'; $i++){ $objPHPExcel->setActiveSheetIndex(0)->getColumnDimension($i)->setAutoSize(TRUE); } $objPHPExcel->getActiveSheet()->setTitle('Inase'); $objPHPExcel->setActiveSheetIndex(0); $objPHPExcel->getActiveSheet(0)->freezePaneByColumnAndRow(0,4); header('Content-Type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'); header('Content-Disposition: attachment;filename="ReportedeInase.xlsx"'); header('Cache-Control: max-age=0'); $objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel2007'); $objWriter->save('php://output'); exit; } else{ print_r('No hay resultados para mostrar'); } exit; mysql_close (); ?>