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

Free Support Forum - aspose.com

OLE Excel Object Size is Changed after Double Click on it in MS Word | Insert OLE (Excel) into Document using .NET


Please manually create the expected Excel document using MS Excel that you want to insert into MS Word document. Please insert this document into Word document using MS Word and check the MS Word’s behavior. You will notice the same behavior.

If you notice different behavior, please share following resources here for testing.

  • Your expected Excel document that you want to insert into Word document. Please create this document using MS Excel.
  • Please attach the output Excel document that is generated by Aspose.Cells and shows undesired behavior and .
  • Please share Aspose.Cells code example to generate Excel document.

We will then investigate the issue and provide you more information on it. If Aspose.Cells does not generate the expected Excel output, we will log this issue for Aspose.Cells.

PS: To attach these resources, please zip and upload them.

You’ve completely ignored what I wrote in my post. Are you not understanding the point I am making or is what I stated somehow incorrect?


We have investigated this issue further and noticed that the OLE Shape width does not set correctly. The Shape.Width should be equal to size set by SetOleSize method.

The Shape.Width does not change the width of OLE as MS Word does. We have logged this detail in our issue tracking system and you will be informed once there is any update available on it.


Further to my previous post, you can set the OLE width using following code snippet. The Shape width should be the size of OLE set by SetOleSize.

Bitmap bitmap = sr.ToImage(0);
shape.Width = bitmap.Width;

Hope this helps you.

Ok that makes sense. So you are acknowledging that shape.Width not taking effect is a bug and will be fixed at some point?


This code will solve your problem. However, as shared in my previous post, the Shape.Width sets the shape size but not the internal OLE size.

It is more related to missing feature in Aspose.Words. We will check the possibility of implementation of this feature and inform you via this forum thread.

Well it doesn’t actually solve my problem because I need to resize the image to get it to fit properly into the document, but I am glad to hear that you will be looking into it. Here is updated code:

    static void TestAspose()
        var book = new Aspose.Cells.Workbook(@"C:\Projects\WordTest\sample.xlsx");

        var sheet = book.Worksheets[0];

        book.Worksheets.SetOleSize(0, sheet.Cells.MaxDataRow, 0, sheet.Cells.MaxDataColumn);

        sheet.PageSetup.LeftMargin = 0;
        sheet.PageSetup.RightMargin = 0;
        sheet.PageSetup.TopMargin = 0;
        sheet.PageSetup.BottomMargin = 0;

        var options = new Aspose.Cells.Rendering.ImageOrPrintOptions
            OnePagePerSheet = true,
            ImageType = Aspose.Cells.Drawing.ImageType.Emf

        var sr = new Aspose.Cells.Rendering.SheetRender(sheet, options);

        var imgStream = new MemoryStream();
        sr.ToImage(0, imgStream);
        imgStream.Position = 0;

        using var image = Aspose.Imaging.Image.Load(imgStream);
        imgStream.Position = 0;

        var document = new Aspose.Words.Document();
        var builder = new Aspose.Words.DocumentBuilder(document);
        using var xlsStream = new MemoryStream();

        book.Save(xlsStream, SaveFormat.Xlsx);
        xlsStream.Position = 0;
        var shape = builder.InsertOleObject(xlsStream, "Excel.Sheet.12", false, imgStream);

        var of = shape.OleFormat;
        of.AutoUpdate = false;

        shape.AspectRatioLocked = true;
        shape.Width = image.Width;



We will inform you via this forum thread once there is any news available on WORDSNET-22615.