NPOI实现:
/// <summary>
/// .xls后缀的Excel文件添加图片
/// </summary>
/// <param name="book"></param>
/// <param name="sheet1"></param>
/// <param name="rowindex"></param>
/// <param name="imgPath"></param>
private static void InsertImageToExcel(HSSFWorkbook book, ISheet sheet1, int rowindex, string imgPath)
{
byte[] bytes = System.IO.File.ReadAllBytes(imgPath);
int pictureIdx = book.AddPicture(bytes, PictureType.JPEG);
HSSFPatriarch patriarch = (HSSFPatriarch)sheet1.CreateDrawingPatriarch();
HSSFClientAnchor anchor = new HSSFClientAnchor(30, 25, 0, 0, 4, rowindex, 5, rowindex);
HSSFPicture pict = (HSSFPicture)patriarch.CreatePicture(anchor, pictureIdx);
pict.Resize();//自动调节图片大小
}