Removes cell comments.
The ClearComments method removes cell comments only. Cell content, formatting and hyperlinks remain unchanged. Another way to do this is to use the CommentCollection.Remove or CommentCollection.RemoveAt method of the Worksheet.Comments collection.
To separately remove cell content, formatting, hyperlinks or clear a cell range completely, call the Worksheet.ClearContents, Worksheet.ClearFormats, Worksheet.ClearHyperlinks or Worksheet.Clear method, respectively. To delete entire cells from the worksheet, use the Worksheet.DeleteCells method (see the How to: Delete a Cell or Range of Cells example).
To clear cells, you can also use the range's Clear* extension methods, defined by the RangeExtensions class (RangeExtensions.Clear, RangeExtensions.ClearContents, RangeExtensions.ClearFormats, RangeExtensions.ClearHyperlinks and RangeExtensions.ClearComments). These extension methods are accessible as methods of the Range object and called by using the instance method syntax.
This example demonstrates how to clear worksheet cells.
To remove all cell information (content, formatting, hyperlinks and comments), call the Worksheet.Clear method.
Clear Cell Content
Clear Cell Formatting
Clear Cell Hyperlinks
You can also get hyperlinks contained in the specified cell range via the HyperlinkCollection.GetHyperlinks method and remove them using the HyperlinkCollection.Remove method of the Worksheet.Hyperlinks collection. In this case, cell formatting is also cleared.
Clear Cell Comments
To remove any comments contained in a cell or cell range, call the Worksheet.ClearComments method, or remove comments from the worksheet's Worksheet.Comments collection via the CommentCollection.Remove or CommentCollection.RemoveAt method.
A complete sample project is available at https://github.com/DevExpress-Examples/spreadsheet-document-server-api-e4339
// Remove all cell information (content, formatting, hyperlinks and comments). worksheet.Clear(worksheet["C2:D2"]); // Remove cell content. worksheet.ClearContents(worksheet["C3"]); worksheet["D3"].Value = null; // Remove cell formatting. worksheet.ClearFormats(worksheet["C4"]); worksheet["D4"].Style = workbook.Styles.DefaultStyle; // Remove hyperlinks from cells. worksheet.ClearHyperlinks(worksheet["C5"]); Hyperlink hyperlinkD5 = worksheet.Hyperlinks.GetHyperlinks(worksheet["D5"]); worksheet.Hyperlinks.Remove(hyperlinkD5); // Remove comments from cells. worksheet.ClearComments(worksheet["C6"]); Comment commentD6 = worksheet.Comments.GetComments(worksheet["D6"]); worksheet.Comments.Remove(commentD6);