Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $tipo = isset($_REQUEST['formato']) ? $_REQUEST['formato'] : 'excel';
- $extension = '.xlsx';
- if($tipo == 'txt') {$extension = '.txt';}
- // Si queremos exportar a PDF
- if($tipo == 'txt'){
- header('Expires: 0');
- header('Cache-control: private');
- header('Content-Type: application/x-octet-stream'); // Archivo de Excel
- header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
- header('Content-Description: File Transfer');
- header('Last-Modified: '.date('D, d M Y H:i:s'));
- header('Content-Disposition: attachment; filename="Reporte$extension');
- header("Content-Transfer-Encoding: binary");
- } else{
- header('Content-Type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet');
- header('Content-Disposition: attachment;filename="Reporte$extension"');
- header('Cache-Control: max-age=0');
- $objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel_Nuevo, 'Excel2007');
- $objWriter->save('php://output');
- exit;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement