通过php提取excel中动态变化的数据

发布于 2025-01-01 08:56:52 字数 302 浏览 4 评论 0原文

我有一个打开的 Excel 工作表,另一个程序通过 DDE 不断更新该工作表。我希望有一个 php 脚本来访问此 Excel 工作表中的一些数据。我尝试过使用 PHPExcel,但似乎我无法让我所做的更改(例如通过 setCellValue)立即反映在打开的 Excel 工作表中。同样,如果我更改单元格的值(不将工作表保存到文件系统),则无法通过 getValue() 获得单元格的新值。

phpExcel 支持此功能吗?如果是这样,有人可以向我指出说明如何做到这一点的文档吗?或者,是否有另一种方法(例如不使用 phpExcel)来执行此操作?

谢谢。

I have an open excel sheet that's constantly being updated by another program via DDE. I wish to have a php script that accesses some of the data in this excel sheet. I have tried using PHPExcel and it seems that I cannot have the changes I make (e.g. via setCellValue) being immediately reflected in the open excel sheet. Similarly, if I change value of a cell (without saving sheet to the file system) the new value of the cell is not available via getValue().

Is this functionality supported by phpExcel? If so, could someone please point me to documentation that shows how this can be done? Alternatively, is there another way (not using phpExcel, for example) to do this?

Thanks.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

悲凉≈ 2025-01-08 08:56:52

我能够使用 稀有博客网页

这对我有用,两者都用于将单元格值从 php“推送”到 excel,以及从 excel 获取修改后的值(不保存文件)到 perl。该网站还有一个基于 ajax 的漂亮功能,可以使用 Excel 中的最新值自动刷新我的网页。

非常感谢博客的作者。

I was able to do this using the method shown at the rarified blog webpage

This worked for me, both for "pushing" cell values from php to excel, as well as getting modified values (without saving the file) from excel to perl. This site also has a nifty ajax-based function that keeps auto-refreshing my webpage with the latest values in excel.

Many thanks to the author of the blog.

玩物 2025-01-08 08:56:52

PHPExcel 不支持它...... PHPExcel 在您发出 load() 调用时将工作簿加载到内存中,并且在那时,只要您的 DDE 更改了工作簿,它就无法“自动刷新”,因为DDE 更新是针对磁盘上的工作簿,而不是针对 PHP 内存中的 PHPEXcel 副本。

您需要不断加载和重新加载才能获取对底层文件的更改。

同样,如果您在 PHPExcel 中更改工作簿,除非您显式 save(),否则它不会将该更改写回磁盘上的文件,因此您的 DDE 程序将看不到更改。

我不知道您是否可以使用 MS Excel 本身执行此操作...如果您使用 MS Excel 本身加载工作簿,那么您将从磁盘加载到内存中,如果当时有其他任何东西正在访问该工作簿,您发现你已经以只读模式加载了它,并且(据我所知)每当DDE程序更新原始版本时它都不会自动刷新。如果有任何东西可以按照您需要的方式与此一起工作,那么它很可能是 COM,但我不会让您抱太大希望。

It's not supported by PHPExcel.... PHPExcel loads the workbook into memory at the point in time when you issue the load() call , and at that point it can't "autorefresh" whenever the workbook is changed by your DDE because the DDE update is to the workbook on disk, not the PHPEXcel copy that's in PHP memory.

You'd need to be constantly loading and reloading to pick up changes to the underlying file.

Likewise, if you change the workbook in PHPExcel, it doesn't write that change back to the file on disk unless you explicitly save(), so the change will not be visible to your DDE program.

I'm not aware whether you can even do this with MS Excel itself... if you load a workbook using MS Excel itself, you're loading from disk into memory, and if anything else is accessing that workbook at the time, you find that you've loaded it in read-only mode, and (as far as I'm aware) it won't automatically refresh whenever the DDE program updates the original version. If anything can work with this the way you need, it's likely to be COM, but I wouldn't build up your hopes too much.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文