Re: Insert an Aspose.Cells.Worksheet in an Aspose.Words.Document

Hi Support ,
I also have the same requirement where we need to add a .xls sheet to the word doc . please share the sample code how i achieve these. i am using Aspose.Words for .net.

Mohit

Hi Mohit,


Thanks for your inquiry. Please use the following code example to embed Excel and Word documents into Word document.

Insert embedded Excel 97-2003 document as iconic OLE object from stream using predefined image:

Document doc = new Document();

DocumentBuilder builder = new DocumentBuilder(doc);

Stream memoryStream = File.OpenRead(MyDir + “Book1.xls”);

Shape oleObject = builder.InsertOleObject(memoryStream, “Excel.Sheet.8”, true, null);

doc.Save(MyDir + @“out.docx”);

Insert linked Word document from file as normal OLE object using custom presentation image

Document doc = new Document();

DocumentBuilder builder = new DocumentBuilder(doc);

Image image = Image.FromFile(MyDir + “Aspose.Words.png”);

Shape oleObject = builder.InsertOleObject(MyDir + “Doc1.docx”, true, false, image);

doc.Save(MyDir + @“out.docx”);

I hope, this helps.