This project has moved and is read-only. For the latest updates, please go here.

How to Add Image to Cell

Jan 21, 2014 at 10:44 AM
I have been reading on how to add image to a cell, but I still don't get it. I'm trying to understand how to use the methods.

Is there a simple example to add an image to a cell when a webpage loads. I am using MVC, I have tried this but still can't get the image out.
public ActionResult Index()
        {
            ViewBag.Message = "Modify this template to jump-start your ASP.NET MVC application.";

            ExcelPackage epck = new ExcelPackage();
            var ws = epck.Workbook.Worksheets.Add("Sheet 1");

            
            Image logo = Image.FromFile("heroAccent.png");
            var picture = ws.Drawings.AddPicture(1.ToString(), logo);
            picture.SetPosition(1,1);



            epck.SaveAs(Response.OutputStream);
            Response.ContentType = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet";
            Response.AddHeader("content-disposition", "attachment;  filename=HitterReport.xlsx");

            return View();
        }
How do one add an image to a cell let us say in cell B3?

Thanks