GemBox Support Forum

Method not found: ExcelPicture.ToImage()

System.MissingMethodException: Method not found: ‘System.Drawing.Image GemBox.Spreadsheet.ExcelPicture.ToImage()’

It seems that the method is not available on Linux container? - I think It runs OK on Windows

My dockerfile installation command

RUN apt-get update && apt-get install -y libfreetype6 libfontconfig1 libc6-dev ttf-mscorefonts-installer fontconfig && apt-get clean && rm -rf /var/lib/apt/lists/*

The Gembox.Spreadsheet version is 49.0.1153


Yes, that method returns the System.Drawing.Image object and the problem is that System.Drawing is no longer supported on Linux.

Please check the remarks of the System.Drawing namespace:

Can you tell us what you’re doing with the Image object?


Thanks for the reply.
I would like to scale the current row to the picture’s dimension

var picture = excelWorksheet.Pictures.Add(pictureStream, ExcelPictureFormat.Png,
    currentCell.Name, currentCell.Name);
var image = picture.ToImage();
var scaledHeightInPoint = currentCell.Column.GetWidth(LengthUnit.Point) * image.Height / image.Width;
currentCell.Row.SetHeight(scaledHeightInPoint, LengthUnit.Point);

Would there be another way to achieve that?


Try replacing this:

var image = picture.ToImage();

With this:

var image = SKBitmap.Decode(pictureStream.ToArray());

The SKBitmap class comes from SkiaSharp.

I hope this helps.


Thanks, Mario.

I would like to ask also if FormControls.AddCheckBox have some issues with Linux also?
I am rendering the excel content to PDF and it worked fine on Windows. Linux refuses to render the checkbox

using var resultExcelStream = new MemoryStream();
resultExcel.Save(resultExcelStream, GemBox.Spreadsheet.SaveOptions.PdfDefault);


I believe your problem occurs because of the font that is used to render that content.
Try adding the “Segoe UI Emoji” font to your project.

For example, create a “Fonts” folder inside the project and add the “seguiemj.ttf” file to it.
Set the font file to be copied to the output directory:

  <None Update="Fonts\seguiemj.ttf">

Set the FontsBaseDirectory property to that folder:

FontSettings.FontsBaseDirectory = "Fonts";

Does this solve your issue?


Thank you a lot Mario. The above answers helped us to solve almost all the problems. I have some small issues with the font being rendered differently on Linux vs Windows but I will make some more testing :smiley: