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

旧街凉风 提交于 2020-05-29 05:41:12

问题


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.


回答1:


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;
    }



回答2:


all xlsx files are really zip files. you can copy/rename the .xlsx extension to .zip and navigate the folder hierarchy yourself. navigate to xl/media to see your images. there are certainly more efficient ways of doing this, but this is a quick and dirty solution that will get the job done.



来源:https://stackoverflow.com/questions/36457242/how-to-get-read-picture-from-excel-file-xlsx-using-epplus

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!