Free Support Forum -

Issue with Image presentation vector based emf files/streams

I’ve try to work with builder.InsertOleObject and I’ve got few issues with the Image presentation of the OLE object. I want to pass a vector based emf files/streams the same way Microsoft Words generate its preview when it embed an excel OLE object. So far it only accept an SKBitmap format.


1 Like


To ensure a timely and accurate response, please attach the following resources here for testing:

  • Your input Word document.
  • Please attach the output Word file that shows the undesired behavior.
  • Please attach the expected output Word file that shows the desired behavior.
  • Please create a standalone console application ( source code without compilation errors ) that helps us to reproduce your problem on our end and attach it here for testing.

As soon as you get these pieces of information ready, we will start investigation into your issue and provide you more information. Thanks for your cooperation.

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

Right now I forced to use Aposes.Cell for generating the preview images as a bitmap. I would like to be a vector EMF preview just like Words is doing when inserting an excel sheet into a pages.

It should exist an easier route, any inquires?

Embed Excel into Word (83.6 KB)


Your issue is more related to Aspose.Cells. We are investigating this issue and will get back to you soon.


Thank you,

Well this is a Aspose.Words issue since the «builder.InsertOleObject(stream, “Excel.Sheet.12”, false, img);» only accept bitmaps as img. I’m using Asposes.Cells to generate the image, do you have any others way using Aspose.Words only for embedding the .xlsx files with it’s preview image into a word documents?


The image presentation of OLE object is inserted correctly by DocumentBuilder.InsertOleObject method. We suggest you please use PageSetup.BottomMargin as shown below. Hope this helps you.

Aspose.Cells.Worksheet sheet = book.Worksheets[1];
sheet.PageSetup.BottomMargin = 0.05;

The InsertOleObject inserts the OLE object into document. However, for image presentation, you need to use Aspose.Cells.


The image presentation of OLE object is inserted correctly by DocumentBuilder.InsertOleObject method. We suggest you please use PageSetup.BottomMargin as shown below. Hope this helps you.

Thank you, I know my code work, but this method gives me a low quality output. What I want is a hi-res image presentation in vector EMF. Just like Word is doing normally when copy-paste an excel worksheet in a doc, or edit the OLE and regenerating the image presentation. The builder.InsertOleObject method should accept vector SkShape, not only SKBitmap type.

1 Like

Hi Mr. tahir, the problem is that insertOLEobject seems to only accept SKBitmap image format. We need EMF image format.

@mathieu1er, @bigmac2

Following code example shows how to get worksheet image as EMF and insert OLE object into Word document. Hope this helps you.

FileStream stream = File.OpenRead(MyDir + "smallSheet.xlsx");
FileStream stream2 = File.OpenRead(MyDir + "smallSheet.xlsx");

Aspose.Cells.Workbook book = new Aspose.Cells.Workbook(stream2);
// extract the spreadsheet from the workbook
Aspose.Cells.Worksheet sheet = book.Worksheets[1];
// prepare aspose to render image from spreadsheet
// Set all margins as 0
sheet.PageSetup.LeftMargin = 0;
sheet.PageSetup.RightMargin = 0;
sheet.PageSetup.TopMargin = 0;
sheet.PageSetup.BottomMargin = 0.05;
// Set OnePagePerSheet option as true
Aspose.Cells.Rendering.ImageOrPrintOptions options = new Aspose.Cells.Rendering.ImageOrPrintOptions
    OnePagePerSheet = true,
    ImageType = Aspose.Cells.Drawing.ImageType.Emf
// Take the image of your worksheet
Aspose.Cells.Rendering.SheetRender sr = new Aspose.Cells.Rendering.SheetRender(sheet, options);

//sr.ToImage(0, MyDir + "out.emf");
Stream imgStream = new MemoryStream();
// create image memoryStream
sr.ToImage(0, imgStream);

Aspose.Words.Document document = new Aspose.Words.Document();
Aspose.Words.DocumentBuilder builder = new Aspose.Words.DocumentBuilder(document);

Image image = Image.FromStream(imgStream);

builder.Writeln("Spreadsheet Ole object:");
builder.InsertOleObject(stream, "Excel.Sheet.12", false, image);
document.Save(MyDir + "20.6.docx");  

We have attached the output document with this post for your kind reference. (18.3 KB)

Thank you very much for your answer, but it doesnt even compile.
image.png (18.2 KB) (compilation error image)
here is the issue :
image.png (9.2 KB) (format invalid)
as you can see Image format is not accepted. Only SKBitmap is.
and we are using latest Aspose versions
image.png (3.3 KB) (aspose version proof)
Is it an error from our side ?

The code you provided doesn’t work for me, since I’ve got the same error related to the representing image format not been compatible.

Here the error where got:

CS1503	Argument 4: cannot convert from 'System.Drawing.Image' to 'SkiaSharp.SKBitmap'	AsposeSupport	C:\Users\PERMAT1958\source\repos\AsposeSupport\Program.cs	46	Active

Can it be related to .dotnetcore vs .netframework? we are using .netcoreapp 3.1


You can replace following line of code

Image image = Image.FromStream(imgStream);


SkiaSharp.SKBitmap img = SkiaSharp.SKBitmap.Decode(imgStream);

to fix this issue.

I am sorry to say that but no because of 2 points…

Firstly, as you may probably know, the .Decode() method of SKiaSharp.SKBitmap can only decode .gifs , .png and .jpeg image formats.

Second, This will convert the EMF image stream into a bitmap image format… our question is that we dont want to use a SKBitmap image. We want to use a EMF image. This is the whole point of this conversation and the reason we reached you in the first place.

SKBitmap compromises greatly the quality of the preview and is not a vectorial image like microsoft does but a bitmap image which is not great for printing.

Could you help us with this please?
Thank you very much for your time and efforts in helping us with this issue…

ps: here is the result we get with your code fix… image.png (25.7 KB) ( ole object with no image preview at all )

Also… Should’nt the documentation be corrected regarding what we just saw?


We have tested the scenario and have managed to reproduce the same issue at our side. For the sake of correction, we have logged this problem in our issue tracking system as WORDSNET-20736 . You will be notified via this forum thread once this issue is resolved.

We apologize for your inconvenience.