This project has moved. For the latest updates, please go here.

Delete Comment in Excel Cell

Dec 28, 2011 at 8:34 PM

Hello everyone,

Is there a way to delete a comment in a cell? I have tried the Reset() and Clear() method of the ExcelRange class, but it does not work.

May 21, 2012 at 10:15 AM
Edited May 21, 2012 at 12:15 PM
emendezrivas wrote:

Hello everyone,

Is there a way to delete a comment in a cell? I have tried the Reset() and Clear() method of the ExcelRange class, but it does not work.

On the worksheet, there is a Comments collection, which you can use to remove the comments using the .Remove and .RemoveAt methods.

I have found an issue with trying to clear out all comments for a sheet though, for example:

while (_sheet.Comments.Count > 0)
{
    _sheet.Comments.RemoveAt(0);
}

And get the below error that it can't find the key. My problem is that it doesn't always happen, only in some cases.

[Exception: Key does not exist] OfficeOpenXml.RangeCollection.Delete(UInt64 key)

I posted a question to StackOverflow regarding this, see [ http://stackoverflow.com/questions/10684372/removing-clearing-comments-in-excel-with-epplus ]