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.
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;
}
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With