1

What is the best way to insert an image comment to a cell in excel using C#?

I'm using Microsoft.Office.Interop.Excel.

So far I've done

        Microsoft.Office.Interop.Excel.Application excel = new Microsoft.Office.Interop.Excel.Application();

        Microsoft.Office.Interop.Excel.Workbook wb = excel.Workbooks.Open(filename);
        Microsoft.Office.Interop.Excel.Worksheet sheet = wb.Sheets[1];

        var commnetImage = sheet.Shapes.AddPicture(@"d:\download.jpg", Microsoft.Office.Core.MsoTriState.msoTrue, Microsoft.Office.Core.MsoTriState.msoFalse,
            0, 0, 100, 200);

        var gg = sheet.Cells.Range["E5"];
        gg.ClearComments();
        gg.AddComment(commnetImage);
        wb.Save();

        excel.Quit();
  • Have you looked at [the Epplus library](http://epplus.codeplex.com/) for an alternative to using Interops? Interops are generally very slow and untrustworthy. I would suggest having a look at that before continuing with your project. It is a very simple to use library. I have written some example code to get started a view years ago. Have a look at [My blog](http://www.jasonsmith.co.za/2011/03/readingwriting-xlsx-files.html) – Jason Loki Smith Feb 25 '14 at 11:53
  • Jus looking at it now, I see the add comment to cell example, does it support images?? – user3316165 Feb 25 '14 at 11:58

1 Answers1

0

Thank guys, Found solution at

Any open source / free library for handling Excel (both *.xls and *.xlsx) files?

Didn't manage to find it yesterday, it is using this great open source project http://spreadsheetlight.com/

Community
  • 1
  • 1