百度,google找了好一会儿没找到怎么获取指定单元格内的图片,只能自己研究了
添加引用
using OfficeOpenXml;
using System.IO;
using System.Linq;
完整代码
using (ExcelPackage pck = new ExcelPackage(path))
{
string pathurl = Path.Combine(path, "pic");//指定图片保存目录
if (!Directory.Exists(pathurl))
{
Directory.CreateDirectory(pathurl);
}
ExcelWorksheet source_ws = pck.Workbook.Worksheets.FirstOrDefault();//读取第一个sheet表
var excelPicture = source_ws.Drawings.Where(o => o.From.Row == 1 && o.From.Column ==
1).FirstOrDefault() as OfficeOpenXml.Drawing.ExcelPicture;//获取第一行第一列单元格内的图片
var filepath = Path.Combine(pathurl, string.Format("{0}.jpg", DateTime.Now.ToFileTime()));//指定文件名
excelPicture.Image.Save(filepath, System.Drawing.Imaging.ImageFormat.Jpeg);//保存图片
}
来源:oschina
链接:https://my.oschina.net/u/4386603/blog/4600840