Missing schema when inserting image to .xlsx file through OpenXML

429 views Asked by At

I'll try to keep this brief as there is a lot of back-story!

I can use the code from this example to insert an image into a spreadsheet at an absolute position of 0,0 EMUs using an AbsoluteAnchor.

When I try to do the same using a TwoCellAnchor, the drawing comes out corrupted and so Excel offers to clean it up by removing the image completely.

When I compare my 'monstrosity' to a working TwoCellAnchor created from within Excel itself, the only difference is that the second line declaration.

Mine appears as:

<xdr:wsDr xmlns:xdr="http://schemas.openxmlformats.org/drawingml/2006/spreadsheetDrawing">

Whereas the Excel-created one appears as:

<xdr:wsDr xmlns:xdr="http://schemas.openxmlformats.org/drawingml/2006/spreadsheetDrawing" xmlns:a="http://schemas.openxmlformats.org/drawingml/2006/main">

Note the additional schema "xmlns:a". As I, to my knowledge, have not manually set any schema in programming this, I have no idea how to fix this issue. If I go in an manually alter the XML to add this schema then it works fine but obviously this defeats the purpose of programming an automated process.

Would anybody be able to point me out in the direction of a solution to this issue? The amount of useful documentation on the Internet regarding this is very limited it! Thanks.

0

There are 0 answers