php 致命错误:PHPExcel 类中未捕获的异常“异常”

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/2863400/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-25 07:57:20  来源:igfitidea点击:

Fatal error: Uncaught exception 'Exception' in PHPExcel classes

phpexception

提问by Chakrapani

Can any one please let me know, why this following error has been thrown from PHPExcel classes

任何人都可以让我知道,为什么 PHPExcel 类会抛出以下错误

    Fatal error: Uncaught exception 'Exception' with message 'Could not close zip file
 /var/www/mydomain/myexcel.xlsx.' in /var/www/mydomain/Classes/PHPExcel/Writer
/Excel2007.php:400 Stack trace: #0 /var/www/mydomain/myexcel.php(173):
 PHPExcel_Writer_Excel2007->save('/var/www/mydomain...') #1 {main} 
thrown in /var/www/mydomain/Classes/PHPExcel/Writer/Excel2007.php on line 400

回答by wimvds

My educated guess would be that this is due to the fact that the permissions on the folder you're trying to write to are wrong. If that's the case, either make the folder writable (which, from the looks of it would be a bad idea) - or try to save to a location where the web user has write access to solve the problem.

我有根据的猜测是,这是因为您尝试写入的文件夹的权限是错误的。如果是这种情况,要么使文件夹可写(从外观上看这将是一个坏主意) - 或尝试保存到网络用户具有写入权限的位置以解决问题。

BTW What version of PHPExcel are you using?

顺便说一句,您使用的是什么版本的 PHPExcel?

回答by Prabhu M

I hope this exception may occur because of the Excel sheet is still in open state. also please check with the permission of the folder in which you write/save/upload the .xlsx file.

我希望这个异常可能会发生,因为 Excel 工作表仍处于打开状态。还请检查您写入/保存/上传 .xlsx 文件的文件夹的权限。

回答by Scott Jennings

The most likely cause of this error is that you do not have permission to write to the directory you're trying to save the Excel file to.

此错误的最可能原因是您无权写入要尝试将 Excel 文件保存到的目录。

回答by Mark Baker

The exception is being thrown because PHPExcel has opened the zip file for writing the Excel workbook; but when it tries to close it again on completion, the zip library method call to close() has failed. Why it has failed is the real problem, and that can't be resolved simply by knowing the error message.

抛出异常是因为 PHPExcel 已打开用于编写 Excel 工作簿的 zip 文件;但是当它尝试在完成时再次关闭它时,对 close() 的 zip 库方法调用失败。它失败的原因是真正的问题,不能仅仅通过了解错误消息来解决。

回答by ProfVersaggi

I had this same problem - here is how I solved it: Traditionally PHP runs as the web server daemon, so it would stand to reason that the web server daemon would need to write in that subdirand should be the group owner of the entire Examples subdir. I made that simple change and it worked perfectly.

我遇到了同样的问题 - 这是我解决它的方法:传统上 PHP 作为Web 服务器守护程序运行,因此有理由认为Web 服务器守护程序需要在该子目录中写入并且应该是整个示例的组所有者子目录。我做了那个简单的改变,它工作得很好。