title: Removing / clearing comments in Excel with EPPlus
body: <p>I am having some problems working with comments in Excel docs using EPPlus. I can add comments and remove them, however sometimes it isn't successful.</p>
  
  <p>I am using the comments to display validation messages from the result of processing the Excel file, and when this file gets re-processed, I want to clear any existing comments before running the validation again.</p>
  
  <p>My current method of clearing the comments is this:</p>
  
  <pre><code>  _sheet.Cells.Style.Fill.PatternType = ExcelFillStyle.None;
    while (_sheet.Comments.Count &gt; 0)
    {
        // Note: not using _sheet.Comments.RemoveAt(0) since this can throw [Exception: Key does not exist] OfficeOpenXml.RangeCollection.Delete(UInt64 key) 
        _sheet.Comments.RemoveAt(_sheet.Comments.Count - 1);
    }
  </code></pre>
  
  <p>Which seems to clear them fine. But when I try to add a comment as below:</p>
  
  <pre><code>  const string author = "...";
    cell.Style.Fill.PatternType = ExcelFillStyle.Solid;
    cell.Style.Fill.BackgroundColor.SetColor(Color.LemonChiffon);
    if (cell.Comment == null)
    {
        cell.AddComment(message, author);
    }
    else
    {
        cell.Comment.Text = message;
        cell.Comment.Author = author;
    }
  </code></pre>
  
  <p>where cell is an ExcelRange instance for a specific cell, I get the below stack trace:</p>
  
  <pre><code>System.NullReferenceException : Object reference not set to an instance of an object.
  at OfficeOpenXml.Drawing.Vml.ExcelVmlDrawingCommentCollection.AddDrawing(ExcelRangeBase cell)
  at OfficeOpenXml.Drawing.Vml.ExcelVmlDrawingCommentCollection.Add(ExcelRangeBase cell)
  at OfficeOpenXml.ExcelComment..ctor(XmlNamespaceManager ns, XmlNode commentTopNode, ExcelRangeBase cell)
  at OfficeOpenXml.ExcelCommentCollection.Add(ExcelRangeBase cell, String Text, String author)
  at OfficeOpenXml.ExcelRangeBase.Set_Comment(Object value, Int32 row, Int32 col)
  at OfficeOpenXml.ExcelRangeBase.SetSingle(_setValue valueMethod, Object value)
  at OfficeOpenXml.ExcelRangeBase.AddComment(String Text, String Author)
  </code></pre>
  
  <p>Can anyone help me with this? What am I doing wrong?</p>
  
  <p>Thanks,</p>
  
  <p>James</p>