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.
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?
Thanks
This actually is unfortunately not that easy. I do have a similar problem with PowerPoint.
To embed an OLE Object into an Excel workbook, the actual application has to be started and asked for two different things:
- a "screenshot", typically a generated emf file of the document to be inserted for the user to get an idea of the content of the document
- the actual file to be embedded which can be different from the original source file
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.
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.
--- update ---
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.