0

Normaly in my application system i am able to export content via PHP Exel. Now i can export the .xlsx file but if i would like to open it ill get the message : Can not open file because format or filename extension is invalid.

Error Code :

Fatal error: Uncaught exception 'Exception' with message 'Could not close zip file php://output.' in /net/myvm0364/disc1/www/pc2/application/include/847dfknsa_2434_phpExcel/PHPExcel/Writer/Excel2007.php:346 Stack trace: #0 /net/vmits0364/disc1/www/pc2/application/include/exportMember.php(188): PHPExcel_Writer_Excel2007->save('php://output') #1 {main} thrown in /net/myvm0364/disc1/www/pc2/application/include/847dfknsa_2434_phpExcel/PHPExcel/Writer/Excel2007.php on line 346

Did somebody know what i have to do ?

Lelio Faieta
  • 6,457
  • 7
  • 40
  • 74
  • ok to share the error message but the code? – Lelio Faieta Jan 17 '19 at 08:54
  • Do you have Suhosin installed on your server? It has probably got something to do with rights. Does your destination folder has rwxrwxrwx (0777) rights? – WKoppel Jan 17 '19 at 09:08
  • @WKoppel 777? why? you just need to give your webserver full access, not the whole world! – Lelio Faieta Jan 17 '19 at 09:12
  • I said destination folder @LelioFaieta – WKoppel Jan 17 '19 at 09:12
  • Yes. That’s exactly what I am talking about. – Lelio Faieta Jan 17 '19 at 09:14
  • If it's an tmp folder only for example then what's the problem? @LelioFaieta – WKoppel Jan 17 '19 at 09:15
  • @WKoppel you are suggesting a dangerous practice as normal. there is nothing here related to something about temp folders or examples. 3. this is not fixing the issue at all so you are just introducing in op's code a new bug – Lelio Faieta Jan 17 '19 at 09:32
  • Possible duplicate of [PHPExcel\_Writer\_Exception with message "Could not close zip file php://output."](https://stackoverflow.com/questions/21436949/phpexcel-writer-exception-with-message-could-not-close-zip-file-php-output) – Lelio Faieta Jan 17 '19 at 09:34
  • @masterriemi1702 if you just google for the error you get you will see how to fix it. See [this answer](https://stackoverflow.com/questions/21436949/phpexcel-writer-exception-with-message-could-not-close-zip-file-php-output) for example – Lelio Faieta Jan 17 '19 at 09:35

1 Answers1

0

I have seen a similar case before on my server (then I used CSV because do not solve problem). The reason is that the excel file is too large (about 40000 or 50000 records, or file size larger than 15MB), making your server can't handle, so excel file will be broken.

Example:

The file content if successfully created is 20MB, but when the file creates 15MB, your server is overload, it will stop the process here. You can still create an excel file but can't open it.

You can try creating an excel file with a capacity of about 1MB or less than, if it work the problem may not be due to your code.

Hope can help you.

So sorry because bad english.

Trung
  • 135
  • 1
  • 13