We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy.
Unfortunately, activation email could not send to your email. Please try again.

Insert a logo in cell

Thread ID:





81124 May 13,2009 03:15 PM May 14,2009 05:28 AM Windows Forms 1
Tags: XlsIO
Administrator [Syncfusion]
Asked On May 13, 2009 03:15 PM

I want to insert a logo into a cell on the sheet.

I know how to insert a chart into a shape that takes a whole worksheet

MemoryStream memImg = (item as Chart).GetImage();
System.Drawing.Image newImage;
newImage = System.Drawing.Image.FromStream(memImg, true);

IWorksheet sheet = m_WorkBook.Worksheets.Create();
sheet.Shapes.AddPicture(newImage, "myChart", ExcelImageFormat.Original);
sheet.IsGridLinesVisible = false;
sheet.IsRowColumnHeadersVisible = false;

How do I insert a logo (bmp, jpeg, etc) into a cell (or at least anchored to a cell)


Geetha M [Syncfusion]
Replied On May 14, 2009 05:28 AM

Hi Kelley,

Thank you for your interest in Syncfusion products.

Please try using the code snippet given below:

IWorksheet sheet = workbook.Worksheets[0];
Image img = Image.FromFile(@"..\..\logo.jpg");
sheet.Pictures.AddPicture(1, 1, img);

// '1' is the column index
sheet.SetColumnWidthInPixels(1, img.Width);
sheet.SetRowHeightInPixels(1, img.Height);

sheet.Pictures[0].IsMoveWithCell = true;
sheet.Pictures[0].IsSizeWithCell = true;

The above code will resize the image along with cell resize. This is equivalent to set the image properties in MS Excel by right clicking the image.

Please try this and let me know if you have any questions.



This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.