1
I have a problem trying to export file to Excel in PHP.
I tried with the library PHPExcel
even though it is obsolete/discontinued and I tested with PhpSpreadSheet
also. But both presented the same error and only in PHP 7.1.20.
Error presented:
"excel cannot open the file because of the format or extension of file is not valid"
When opened with a text editor, display this message:
Fatal error: Uncaught Phpoffice Phpspreadsheet Writer Exception: Could not open php://output for writing. in C: DESENV Defaultcollection Stcpwebadmin Site www cgi-bin libs vendor phpoffice phpspreadsheet src Phpspreadsheet Writer Xlsx.php:218
Stack trace: < #0 C: DESENV Defaultcollection Stcpwebadmin Site www stcpwebversionxls.php(104): Phpoffice Phpspreadsheet Writer Xlsx->save('php://output')
< #1 {main} thrown in C: DESENV Defaultcollection Stcpwebadmin Site www cgi-bin libs vendor phpoffice phpspreadsheet src Phpspreadsheet Writer Xlsx.php online 218
I tested in versions 7.1.14 and 7.1.17 and worked normally.
You know why?
Try editing the generated file with a text editor and put a snippet
– Jorge Costa
@Jorgecosta added the message to the body as you requested.
– Lucas Souza
What are you using for php wamp server or something ? Put the code you are using to generate the file.
– Jorge Costa
Check that you have access with write permissions to the folder for temporary files to know which one to use sys_get_temp_dir
– Jorge Costa
@Jorgecosta am using Windows IIS and have write permission in folder
– Lucas Souza