PHPExcel generated excel file not working. (File format or extension is invalid)
The PHPExcel sample code runs successfully on my local PC, the file is downloaded to the local file and opens successfully in Excel 2007. But using the same code on my server gives an invalid file for Excel, which, when I OPEN AND REPAIR, then opens successfully.
I do not want to use the Open and Repair option, but only the Open option.
Could not find a problem? Please, help.
$objPHPExcel->setActiveSheetIndex(0); //for XLSX header('Content-Type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'); header('Content-Disposition: attachment;filename="item_list.xlsx"'); header('Cache-Control: max-age=0'); $objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel2007'); $objWriter->save('php://output'); exit;
source share