OpenXML将PDF嵌入到Excel中

问题描述:

我在使用OpenXML将PDF等文件嵌入Excel电子表格时遇到麻烦(Excel 2010).我希望能够模仿您可以在Excel本身中执行的Insert> Object>从文件创建和显示为图标"行为.

I'm having trouble using OpenXML to embed files such as PDFs into Excel spreadsheets (Excel 2010). I want to be able to mimic the Insert>Object>Create From File and 'Display as Icon' behaviour that you can perform in Excel itself.

我已经创建了一个带有所需结果示例的电子表格,并将其与Reflector工具一起使用,该工具非常方便,但是并没有说明这些关系的工作原理.

I've created a spreadsheet with an example of the desired result and used it with the Reflector tool which is quite handy but just doesn't explain how the relationships work.

有人对此有可行的解决方案,或者是否有我可以在其中找到信息的链接?

Does anyone have a working solution to this or a link of where I might be able to find the information?

谢谢

不幸的是,这实际上并不容易.我确实对 PowerPoint 有类似的问题

This actually is unfortunately not that easy. I do have a similar problem with PowerPoint.

要将OLE对象嵌入Excel工作簿中,必须启动实际的应用程序并询问两个不同的事情:

To embed an OLE Object into an Excel workbook, the actual application has to be started and asked for two different things:

  • 屏幕快照",通常是要插入的文档的生成的emf文件,供用户了解文档的内容
  • 要嵌入的实际文件可能与原始源文件不同

因此,使用OpenXml意味着必须自行调用该应用程序. 这里.

So working with OpenXml means the application has to be invoked on your own. The procedure how to accomplish that is described here and here.

实际上,我使用pdfium来获取图片,但是要嵌入的pdf文件与原始文件完全不同.这是我目前停留的地方.

Actually I used pdfium to get the picture, but the pdf file to be embedded is pretty different from the original. This is where I currently stuck.

-更新---

我确实发现了如何做到这一点.仍然需要做一些工作,但是实际上您可以使其运行.请在此处.

I did found out how to accomplish this. Still it is some work to do, but actually you can make it running. Please have a look here.