I\'m using phpexcel for export my query in excel file; however after I created file(which is xslx format), I can not open my file in excel. It gives \"the file format or ext
Following documentation or comments somewhere I read, I had this:
$objWriter = PHPExcel_IOFactory::createWriter($spreadsheet, 'Excel2007');
header('Content-Type: application/vnd.ms-excel');
// etc
instead of
$objWriter = PHPExcel_IOFactory::createWriter($spreadsheet, 'Excel2007');
header('Content-Type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet');
// etc
And that caused Firefox and IE/Edge to append an .xls to the filename and also give the error message when trying to open the file directly instead of downloading it. When downloading the file and opening the spreadsheet though, everything was fine.