Problem with download

Topics: Developer Forum, User Forum
Jun 7 at 11:04 AM
I have a problem with download using this PHPExcel

I'm using codeigniter framework and my php version is 5.6.19 in my xampp5

Im using post method in javascript for call onclick function, and just get the result like this in my console

��ࡱ�����������������;���� ���������������'�������������������������(�������������������������

I dont know how to fix this, I have no error in my console.

This is my code :
function download(){
  $this->load->library('excel');
  $filename         = 'MTD';
  $objReader = PHPExcel_IOFactory::createReader('Excel5');

  $template = 'C:/xampp5.9/htdocs/MTD/assets/media/template/twitter.xls';

  $objPHPExcel = $objReader->load($template);

  $objPHPExcel->getSheet(0)->mergeCells('A9:B9')->setCellValue('A9', 'My Download Table');

  $rows = 15;
  $col = 0;
  
  for ($i=0; $i < COUNT($dt_download); $i++) {
    $objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow($col+$i, $rows+$i, intval($dt_download[$i]['date']));
  }

  $objPHPExcel->getActiveSheet()->setTitle('test');

  $objPHPExcel->setActiveSheetIndex(0);
  
  $objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel5');
  header('Content-Type: application/vnd.ms-excel');
  header('Content-Disposition: attachment;filename="'.$filename.'.xls"');
  header('Cache-Control: max-age=0');
  
  $objWriter->save('php://output');
}
Please help me to fix this issue.