We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Embed word object in Excel using Aspose.Cells

Hi Experts,

I am trying to add embed word object into Excel sheet in .net using Aspose.Cells

I could add the drawing object to excel using aspose.cells but my question is there any possible way to embed word object into Excel worksheet in Aspose.cells or let us know if there any Aspose products would support the feature.

Thanks in advance.
Kalpana

Hi Kalpana,


Thanks for your inquiry. Your query is related to Aspose.Cells APIs. I am moving this forum thread to Aspose.Cells forum where you’ll be guided appropriately

Hi,


Thanks for your posting and using Aspose.Cells.

Please see the following sample code for your reference. Please also see the sample ms-word document, output excel file, sample picture and the screenshot showing the output excel file when the image is double clicked for your reference.

C#
//This is your image file, you can use any
string imgFile = dirPath + “pic.jpg”;

//This is your docx file, you can also use Aspose.Words to create docx file programmatically
string docFile = dirPath + @“source.docx”;

//We need the byte[] byte array for both image and docx file to continue
byte[] binaryImg = File.ReadAllBytes(imgFile);
byte[] binaryDoc = File.ReadAllBytes(docFile);

//Insert OLE object into a workbook
Workbook workbook = new Workbook();
Worksheet worksheet = workbook.Worksheets[0];

int idxOle = worksheet.OleObjects.Add(4, 4, 200, 200, binaryImg);
OleObject objOle = worksheet.OleObjects[idxOle];
objOle.ObjectData = binaryDoc;
objOle.ProgID = “Document”;
objOle.ObjectSourceFullName = “source.docx”;

workbook.Save(dirPath + @“output.xlsx”);

Thanks for your reply. Its working for me only when I have set up the img as a frame. As per your instruction, Inside the frame i have loaded the object data in it.

We have a challenge on loading the frame window(img) with empty content at first time. After double clicking the frame window, it has opening the document content. Is there are any possible way of rendering the object data automatically without clicking the OLE frame at first time.

<img class=“ajT” src=“https://ssl.gstatic.com/ui/v1/icons/mail/images/cleardot.gif” style=“background: url(”//ssl.gstatic.com/ui/v1/icons/mail/ellipsis.png") no-repeat; height: 8px; opacity: 0.3; width: 20px;">

Hi,


I do not think if this is possible manually even using MS Excel. For your information, the word document is actually embedded into MS Excel and is taken as embedded object. When you open the Excel file (containing the embedded document in it) into MS Excel manually, you will see the object is represented by an image frame, so when you double click on it, it will be activated and your underlying actual word document is viewed, so you are in edit mode of MS Word then. Once you click outside of the embedded object it will deactivate it and you are back in MS Excel view. Now you may save the Excel file, so next time when you open it, you can see the embedded document directly without the image frame. But, mind you, if you need to scroll the document to view or manipulate the document, you got to again double click on it.

I think the best way to cope with your scenario, you should take the image of your actual document page (data, contents) by Aspose.Words APIs and specify/use it (either you may save to streams or save to image file on disk) as an image data (for the Ole Object) in your code (via Aspose.Cells APIs).

Hope, this helps a bit.

Thank you.