What's the better way to insert cell comments in excel 2007 files programmatically using c# and .net 3.5?
-
How are you currently working with the document?Mitchel Sellers– Mitchel Sellers2008-10-21 17:46:21 +00:00Commented Oct 21, 2008 at 17:46
-
I'm decompressing the open xml documents and writing the necessary comments?.xml by myself. I'm also writing the relationships, vmlDrawing docs and adding the legacyDrawing element in sheet?.xml. But when i compress the folder, change its extension to .xlsx and try open it in excel i get a error.Adones Cunha– Adones Cunha2008-10-21 17:53:01 +00:00Commented Oct 21, 2008 at 17:53
Add a comment
|
4 Answers
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:
https://learn.microsoft.com/en-us/dotnet/api/microsoft.office.interop.excel.range.addcomment
Also see this too
6 Comments
Lance Roberts
probably need to play with the editor to get the whole link to work
Adones Cunha
Thanks, Kenny. But when i do this my program is starting a process called excel. Does it means i need to have ms excel installed on my computer?
kenny
Yes. Sorry, these interop calls require Excel.
Ian Andrews
Something also worth mentioning is that there are no Excel library redistributables when you use the Interop.Excel. So users of the application also need to have Excel installed on their machine. If you need to write the application for targets that don't have Excel installed locally, you need to modify the .xml directly. I believe there are some good utilities for this out there.
kenny
For those stumbling on this. Since this answer I've used ClosedXML to create/modify Excel files directly. I'm not 100% they allow access to comments, but highly likely. closedxml.codeplex.com
|