php://output doesn’t work in PHPExcel

Topics: Developer Forum, Project Management Forum
Nov 27, 2013 at 9:09 AM
I’ve problem in download excel in to desktop instead of server with using Codeigniter.
I use ” $objWriter->save(‘php://output’); ” and lot of non-readable characters in below and doesn’t popup to ask for save. If I use ” $objWriter->save('myfile.xls’); ” is working and download into server.
7����ܥ5�J��=x��G?��;�yy��߼&I4aZ;�A[�ԓ�{�p0�t���ᵿ��#�k��J�����{�|���O�%���W���KK˷�z�=��{�w�ZY^��RJ�e����#���q�����߸���;묳�n�H��‘q������g���l�cw��ï��3��������\

$this->load->library('PHPExcel');

$objPHPExcel = new PHPExcel();
$objPHPExcel->getProperties()->setTitle("title")->setDescription("description");

$objPHPExcel->setActiveSheetIndex(0);
$objPHPExcel->getActiveSheet()->setCellValue('B4', 'Visa Application Report');

ob_end_clean();

header("Cache-Control: no-store, no-cache, must-revalidate");
header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache");
header('Content-type: application/vnd.ms-excel');
header('Content-Disposition: attachment; filename="myfile.xls"');
header('Cache-Control: max-age=0');

$objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel5');
ob_end_clean();
$objWriter->save('php://output');

$objPHPExcel->disconnectWorksheets();
unset($objPHPExcel);