Free Support Forum - aspose.com

Why always show image first when use oleobjects embed word document into excel sheet

the imagedata property after assigned a image byte[], this image will always show up when user first open the excel sheet, after user click and resize the image, the embeded word document show up ,

btw,the domo or sample also show a image first .

1) can we show the embeded word documnet straight forward in the excelsheet?

2) when i manully insert 'objects' in excelsheet, it working correctly and show embeded word document at once after insert. do i missed some setting in programming?

below are my code

Dim ImageUrl As String = imagepath & "icon.jpg"
Dim fs As FileStream = File.OpenRead(ImageUrl)

Dim imageData(fs.Length) As Byte

fs.Read(imageData, 0, imageData.Length)

fs.Close()
fs = File.OpenRead(docfile)
Dim DocData(fs.Length) As Byte

fs.Read(DocData, 0, DocData.Length)

fs.Close()

ws.OleObjects.Add(nline, 0, 100, 200, imageData)

ws.OleObjects(0).FileType = Aspose.Cells.Drawing.OleFileType.Doc

ws.OleObjects(0).ObjectData = DocData
ws.OleObjects(0).SourceFullName = docfile
ws.OleObjects(0).DisplayAsIcon = False
ws.OleObjects(0).ProgID = "Document"

ws.OleObjects(0).MoveToRange(nline, 0, nline + 15, 8)

Hi,

Thanks for your posting and using Aspose.Cells for .NET.

Actually, when Ms-Excel creates OleObject, it also creates an image and then insert it along with the OleObject itself.

On the other hand, Aspose.Cells cannot create the image of the OleObject, unless it is the image of some chart and worksheet. Even in that case, user have to use Sheet2Image and Chart2Image APIs to create the image of the ole object on a fly.

For other types of Ole Objects like PowerPoint, Word document and Acrobat etc, Aspose.Cells cannot create image at all. To get their images, you need Aspose.Slides, Aspose.Words and some other third party components that could create required image of your ole object.

In short, whenever you need to insert ole object, you will also need its image and to get the image, you need some third party component. If you cannot create image with any such component, then you can use any image and Ms-Excel will replace it with correct image, when user will double click on the ole object.