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. (Last updated on : Nov 16th 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Insert a logo in cell

Thread ID:

Created:

Updated:

Platform:

Replies:

81124 May 13,2009 07:15 PM UTC May 14,2009 09:28 AM UTC WinForms 1
loading
Tags: XlsIO
Administrator [Syncfusion]
Asked On May 13, 2009 07:15 PM UTC

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

Geetha M [Syncfusion]
Replied On 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

CONFIRMATION

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.

Warning Icon 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.Close Icon

;