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. Image for the cookie policy date
close icon

Insert a logo in cell

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)

Thanks,
Kelley

1 Reply

GM Geetha M Syncfusion Team May 14, 2009 09:28 AM UTC

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.

Regards,
Geetha

Loader.
Live Chat Icon For mobile
Up arrow icon