0

Getting excel using PHPExcel library in undifined format, refer the image

enter image description here

and my code is:

$this->load->library('excel');
$sheet = new PHPExcel();
$objWorkSheet = $sheet->createSheet();
$sheet->getProperties()->setTitle('Report')->setDescription('Report');
$sheet->setActiveSheetIndex(0);

$sheet->getActiveSheet()->setCellValue('A1','Career Stage');

$sheet_writer = PHPExcel_IOFactory::createWriter($sheet, 'Excel5');
header('Content-Type: application/vnd.ms-excel');
header('Content-Disposition: attachment;filename="pathways_'.date('dMy').'.xls"');
header('Cache-Control: max-age=0');
$sheet_writer->save('php://output');
VishnuPrasad
  • 1,078
  • 5
  • 17
  • 36
  • Open the file in a text editor. Look for leading/trailing whitespace characters, any BOM header, any plaintext PHP error messages or any html markup in the file, then find where your script is echoing those into the output stream – Mark Baker Dec 08 '14 at 09:15
  • which file, code stuff or downloaded excel file – VishnuPrasad Dec 08 '14 at 09:40
  • Look in the downloaded Excel file..... somewhere in your code, you're probably echoing some output that is being injected into the php://output stream.... you need to identify where your code is generating that output and fix it. Knowing what your script might be outputting should help you locate where it's being generated in your script – Mark Baker Dec 08 '14 at 10:23
  • here i am just putting static value to A1 cell as $sheet->getActiveSheet()->setCellValue('A1','Career Stage'); but its not getting – VishnuPrasad Dec 08 '14 at 11:42
  • Have you looked at the downloaded file in a text editor yet? – Mark Baker Dec 08 '14 at 11:43
  • yeah, went through documentation and i have done as per that... but result fails... – VishnuPrasad Dec 09 '14 at 03:49
  • OK, can you send me a copy of the file so that I can check it – Mark Baker Dec 09 '14 at 07:55

0 Answers0