Is there a way to draw an image directly to the canvas that contains the cells of Excel using VSTO without having to insert a shape?
I have seen it done and I know that it is possible I just can't seem to be able to find a source of information.
Range cell = sheet.Cells[1, 1];
var border = cell.Borders[XlBordersIndex.xlDiagonalDown];
border.Weight = XlBorderWeight.xlThin;
border.LineStyle = XlLineStyle.xlContinuous;
This code snippet seems to produce a drawing inside the canvas of the cell. I need to access the layer that this draws onto.
The example in the video (which you had not posted at the time of my original answer) does not "draw to the canvas," instead the program generates OLE objects and embeds them inside the spreadsheet's cells. This can be seen when the secondary application is used to actually draw the molecules. If there was any doubt whether or not it uses OLE, the name should put them to rest -- it is called MarvinOLE. There is some documentation, including how to interact with other vendors' OLE objects, here. Since OLE is a COM technology, and Excel's interfaces are all COM-based, this works.
If you are 100% committed to learning how to "draw an image directly to the canvas", please ignore the rest of this answer. Since you want to use C# (a .NET language) to interact with Excel's COM interfaces, you'll need to familiarize yourself with the Primary Interop Assemblies. Their reference can be found here. If you are only targeting the newest Excel/Office versions, you may want to look at this SO answer, discussing the "improved" Interop interface. Here's a blogger with an example that might help you get started.
Search for "excel interop oleobjects" or something similar and you will find numerous examples, SO questions, documentation, etc.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With