web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Finance | Project Operations, Human Resources, ...
Answered

add picture in excel using epplus

(0) ShareShare
ReportReport
Posted on by 577

I have a container field in the table and I would like to add in excel.

I tried below code

if(table1.Image1 != conNull())
{
    System.Drawing.Image image1 = table1.Image1;
    var excelImage = worksheet.Drawings.AddPicture("image1",image1);
    excelImage.SetPosition(20, 0, 5, 0);
}

and The type of System.Drawing.Image does not match with container.

How can I add picture in excel using epplus

I have the same question (0)
  • André Arnaud de Calavon Profile Picture
    301,069 Super User 2025 Season 2 on at

    Hi Tony,

    Can you tell if and how this question is related to Dynamics 365? What is EPPlus?

  • Tony Mok Profile Picture
    577 on at

    I need to export the excel with picture added and EPPlus is a .NET library that reads and writes Excel 2007/2010/2013 files using the Open Office Xml format (xlsx)

  • Suggested answer
    André Arnaud de Calavon Profile Picture
    301,069 Super User 2025 Season 2 on at

    Hi Tony,

    Can you answer the question if and how it is related to Dynamics 365? Probably, there is also a forum for EPPlus or you can contact the vendor of this solution for additional help.

  • Verified answer
    Sergei Minozhenko Profile Picture
    23,093 on at

    Hi Tony,

    You are trying to assign x++ container type object to .net Image object. And it can't be done explicitly. Try to convert container to stream and create Image class from the stream.

    Something like this:

    System.Drawing.Image image = System.Drawing.Image.FromStream(Binary::constructFromContainer(your_container).getMemoryStream());

  • Blue Wang Profile Picture
    on at

    Hi Tony,

    What is the object  table1.Image1?

    Add  namespaces.

    using System.Drawing; 
    using OfficeOpenXml.Drawing;

    An example about  get the image from disk.

    https://riptutorial.com/epplus/example/26414/add-an-image-to-a-sheet

  • Tony Mok Profile Picture
    577 on at

    Thank you. Sergei Minozhenko, Blue Wang

    System.IO.MemoryStream MemoryStream = Binary::constructFromContainer(table1.Image1).getMemoryStream();
    
    MemoryStream.Position = 0;
    
    System.Drawing.Image image1 = System.Drawing.Image::FromStream(MemoryStream);

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > Finance | Project Operations, Human Resources, AX, GP, SL

#1
Martin Dráb Profile Picture

Martin Dráb 592 Most Valuable Professional

#2
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 478 Super User 2025 Season 2

#3
BillurSamdancioglu Profile Picture

BillurSamdancioglu 305 Most Valuable Professional

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans