Question

What's the better way to insert cell comments in excel 2007 files programmatically using c# and .net 3.5?

Was it helpful?

Solution

I just did exactly that but with MS Word (using Microsoft.Office.Interop.Word

range.Comments.Add ( range, ref _categoryMessage );

So, I would suggest using Microsoft.Office.Interop.Excel and the similar method. Consider this from MSDN:

http://msdn.microsoft.com/es-es/library/microsoft.office.interop.excel.range.addcomment.aspx

Also see this too

OTHER TIPS

The accepted answer points in the right direction, but the correct syntax is:

Excel.Range cell; 
cell.AddComment("My comment");
Excel._Worksheet oSheet =
  (Microsoft.Office.Interop.Excel._Worksheet) excelWorkbook.ActiveSheet;
oSheet.Cells[2, 3].Cells.AddComment("Selam");

Have you tried using VSTO ? You can easily load an Excel document and manipulate it. To add a comment to a cell, load the file, activate the worksheet, then select the cell as a range and set the comment.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top