Advertisement
EduardoSM

validacion_formato

Dec 9th, 2016
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.98 KB | None | 0 0
  1. <?php
  2. $tipo = isset($_REQUEST['formato']) ? $_REQUEST['formato'] : 'excel';
  3. $extension = '.xlsx';
  4.  
  5. if($tipo == 'txt') {$extension = '.txt';}
  6.  
  7. // Si queremos exportar a PDF
  8. if($tipo == 'txt'){
  9.            
  10. header('Expires: 0');
  11. header('Cache-control: private');
  12. header('Content-Type: application/x-octet-stream'); // Archivo de Excel
  13. header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
  14. header('Content-Description: File Transfer');
  15. header('Last-Modified: '.date('D, d M Y H:i:s'));
  16. header('Content-Disposition: attachment; filename="Reporte$extension');
  17. header("Content-Transfer-Encoding: binary");
  18. } else{
  19.      
  20.       header('Content-Type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet');
  21.       header('Content-Disposition: attachment;filename="Reporte$extension"');
  22.       header('Cache-Control: max-age=0');
  23.     $objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel_Nuevo, 'Excel2007');
  24.     $objWriter->save('php://output');
  25.     exit;
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement