The problem with creating an Excel file in PHP is through PHPExcel. At the output, the file does not want to be downloaded and gives an error, as in the second picture.

Here are the last lines of code in which the file is saved and given to download, as it seems to me, the problem itself lies in it, because if you fix the last line of code, the file is downloaded, but with this error.

// Прописываем заголовки для создания файла header('Content-Type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'); header('Content-Disposition: attachment;filename='. $fileNewName .'.xlsx'); header('Cache-Control: max-age=0'); // Сохраняем и отдаём к скачиванию $objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel2007'); $objWriter->save('php://output'); 

enter image description here

  • who is your $objPHPExcel ? - teran
  • an error in the formation of the file itself, for example, the format of a cell containing the date is incorrect. try to upload a file with just one cell filled with text, will there be an error? - myxaxa

0