使用 DDE 将图像添加到 Excel 工作表

发布于 2025-01-06 18:54:24 字数 347 浏览 0 评论 0原文

我正在开发一个 Delphi 项目,我需要将值导出到 Excel 工作表。 我的项目支持两种实现此目的的方法: 1) 使用 thied party dll 来管理工作表创建 2)使用内置的dde,并通过它执行命令。

两种方法都很好用,但现在我想添加对将图像导出到 Excel 工作表的支持。使用第一种方法,这很容易完成。

我的问题是如何使用 DDE 命令将图像添加到 Excel 工作表?所有支持的 dde ​​命令的完整列表也将不胜感激。我已经来到 this 但它似乎并没有解决我的问题.. ..

I am working on a Delphi project, where i need to export values to excel sheets.
My project supports two ways of accomplishing this:
1) using thied party dll that manages the sheet creation
2) using built in dde, and executing commands over this.

Both ways work nice, but now i want to add support for exporting images to excel sheets. using the first way, this was easily accomplished.

My question is how can I add images to excel sheet, using a DDE command? A full list of all supported dde commands, would also be appreciated. I have come to this but it doesn't seem to solve my problem....

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

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

发布评论

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

评论(3

忘年祭陌 2025-01-13 18:54:24

弄清楚 OLE 与 Excel 通信的正确语法可能非常痛苦,甚至是不可能的。我从未找到有关如何从 Delphi 执行此操作的完整文档。我通常最终会进行大量的试验和错误测试,添加和删除括号和方括号等。Excel 中针对格式不正确的语法发出的错误消息毫无价值,这于事无补。

我建议您考虑一种混合方法,使用 Delphi 在 Excel 中启动宏,如有必要,先将参数插入隐藏 (xlVeryHidden) 工作表。然后,您可以在 VBA 中完成所有操作,这打开了示例代码和支持的世界(例如,MrExcel.com 论坛是一个极好的帮助来源。)

您知道 Deborah Pate 的网站,不: http://www.djpate.freeserve.co.uk/AutoExcl.htm

Figuring out the proper syntax for OLE communication with Excel can be a real pain or impossible. I've never found complete documentation on how to do it from Delphi. I usually end up doing a lot of trial and error testing, adding and removing parentheses and square brackets, etc. It doesn't help that the error messages from Excel for ill-formed syntax are worthless.

I'd suggest that you consider a hybrid approach where you use Delphi to start macros in Excel, previously poking arguments into a hidden (xlVeryHidden) worksheet if necessary. You can then do everything in VBA, which opens up a world of sample code and support (MrExcel.com forums are an excellent source of help, for example.)

You're aware of Deborah Pate's site, no: http://www.djpate.freeserve.co.uk/AutoExcl.htm

陌路黄昏 2025-01-13 18:54:24

仅使用 DDE 无法做到这一点。

我相信正确的方法不是 DDE 而是 OLE Automation(COM IDispatch 接口)。 DDE 仅适用于通过其三个主要读/写/执行命令将您的应用程序链接到另一个应用程序,因此功能比 OLE 自动化更有限。您可以是 DDE 客户端,并且可以连接到 Excel。 Excel 可以是 DDE 服务器或 DDE 客户端。在这种情况下,您可以使用 Excel 并使用 DDE 轻松编写文本。

然而,我不相信您可以将位图图像信息放入 DDE 写入中,但是您可以写入文本、数字和公式。我在 Excel 和 Delphi 中大量使用了 DDE,但从未看到任何迹象表明这是可能的。 DDE有3个基本操作:

  • peek(读)

  • poke(写)

  • execute(调用函数)

如果您问如何使用 OLE 自动化来做到这一点,那将是另一回事,并且使用 Delphi 会相对容易,因为 Delphi 流畅地支持 COM 和 OLE 自动化。

罗伯特·弗兰克的回答似乎也不错。您可以使用 VBA 宏并从 DDE 执行调用它们,但我无法建议如何操作。

You can't do it with only DDE.

I believe the correct approach is not DDE but OLE Automation (COM IDispatch interface). DDE is only useful for linking your app to another app via its three main read/write/execute commands and so the capabilities are more limited than OLE Automation. You can be a DDE client and you can connect to Excel. Excel can be a DDE server or DDE client. In this case you could use Excel and write text easily using DDE.

I do not believe you can put bitmap image information into a DDE write, however, but you can write text, numbers and formulas. I have used DDE heavily with Excel and Delphi, and have never seen any indication that it is possible. DDE has three basic operations:

  • peek (read)

  • poke (write)

  • execute (call function)

If you had asked how to do it with OLE Automation, that would be another matter, and would be relatively easy, with Delphi, since Delphi supports COM and OLE Automation fluently.

Robert Frank's answer seems good too. You could possibly use VBA macrosand invoke them from DDE Execute but it's beyond my capabilities to suggest how.

夜还是长夜 2025-01-13 18:54:24

就我而言,它使用以下命令:

EXCEL ->系统-> [INSERT.PICTURE("C:\temp\picture.jpg")]

In my case it worked with the following command:

EXCEL -> SYSTEM -> [INSERT.PICTURE("C:\temp\picture.jpg")]

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