Issue
this is my simple code to create an xlsx file and open it with openoffice
require(APPPATH.'/PHPExcel-1.8/Classes/PHPExcel.php');
require(APPPATH.'/PHPExcel-1.8/Classes/PHPExcel/Writer/Excel2007.php');
$this->load->library('excel');
$objPHPExcel = new PHPExcel();
$objPHPExcel->setActiveSheetIndex(0)
->SetCellValue('A1', 'Calendario Attivit');
$filename = "prova".".xlsx";
header("Content-Type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
header('Content-Disposition: attachment;filename="'.$filename.'"');
header("Cache-Control: max-age=0");
$objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel2007');
$objWriter->save('php://output');
exit;
the file is downloaded but when open it i get this:
someone can help me ?
Solution
Try to add ob_end_clean()
before the output :
$objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel2007');
ob_end_clean();
$objWriter->save('php://output');
Answered By - Hasta Dhana
0 Comments:
Post a Comment
Note: Only a member of this blog may post a comment.