本文介绍了PHP COM(OLE)连接到MS Excel的对象的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的设置:IIS 7.5,PHP 5.4,Windows 7

My setup: IIS 7.5, PHP 5.4, Windows 7

我试图创建一个 COM对象通过PHP,但我继续获得访问被拒绝。我也跟着一些教程如何授予访问到ISUR创建对象,但没有效果。我读了与COM接口相关的安装部分,说:

I've trying to create a COM Object through PHP but I continue to get access denied. I've also followed a handful of tutorials on how to "grant access" to the ISUR to create the object but to no avail. I read the installation portion relevant to COM interfacing that says:

您负责为您打算使用的各种COM对象
(如MS Word)安装支持;我们不能,也不能捆绑
所有这些与PHP。

You are responsible for installing support for the various COM objects that you intend to use (such as MS Word); we don't and can't bundle all of those with PHP.

我已启用php_com_dotnet.dll文件在ini文件,但我仍然不能创建Excel的COM对象。然后,如果你阅读第二段,它说,你必须安装支持的各种COM对象,你打算使用,但没有指定如何去这样做。

I've enabled the php_com_dotnet.dll file within the ini file but I still can't seem to create the COM object for Excel. Then if you read the second paragraph it says that you have to install support for the various COM objects you intend to use but doesn't specify how to go about doing that.

问题:如何安装对MS Excel COM对象的支持?

Question: How do I install support for the MS Excel COM object?

任何帮助将不胜感激。我已经研究过这个问题,但没有找到太多的文档。

Any help would be appreciated. I've researched this issue but haven't found very much documentation out there.

推荐答案

不要这样做。你在一个痛苦的世界试图在一个Web应用程序,特别是从PHP启动Excel。

Don't do this. You're in for a world of pain trying to launch Excel in a web application, especially from PHP.

Microsoft Office应用程序(如Word和Excel)不是为服务器端使用而设计的。当你试图实例化一个ExcelCOM对象,你正在旋转一个完整的Excel实例作为一个单独的过程。这是非常昂贵的,永远不会扩展。不仅如此,为了增加你的困扰,如果无论什么原因你的脚本不能释放和关闭Excel,你会得到几十或可能数百孤立的Excel进程挂在内存中。

Microsoft Office apps such as Word and Excel are not designed for server side use. When you try to instantiate an Excel "COM object" you're spinning up a full instance of Excel as a separate process. That is hugely expensive and will never scale. Not only that, to add to your woes, if for whatever reason your script can't release and shut down Excel you'll end up with tens or possibly hundreds of orphaned Excel processes hanging around in memory.

尝试类似的操作:如果您需要阅读和编写Excel兼容的电子表格。

Try something like: https://github.com/PHPOffice/PHPExcel if you need to read and write Excel compatible spreadsheets.

这篇关于PHP COM(OLE)连接到MS Excel的对象的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-05 00:40