Search code examples
c#epplus

How to get/read picture from Excel file (xlsx) using EPPlus


Let's assume I have a worksheet named sheet1 which contain a picture named pic_001 How can I get this picture as System.Drawing.Image object.


Solution

  • OK I found out how to:

    public static Image GetImage(string sheetname, ExcelPackage excelFile)
        {
          var sheet = excelFile.Workbook.Worksheets[sheetname];
          var pic = sheet.Drawings["pic_001"] as ExcelPicture;
          return pic.Image;
        }