Skip to main content
.NET Framework 4.5.2+

Worksheet.ClearComments(CellRange) Method

Removes cell comments.

Namespace: DevExpress.Spreadsheet

Assembly: DevExpress.Spreadsheet.v22.1.Core.dll


void ClearComments(
    CellRange range


Name Type Description
range CellRange

A CellRange object specifying the cell range to clear.


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 CellRange object and called by using the instance method syntax.


This example demonstrates how to clear worksheet cells.

// Remove all cell information (content, formatting, hyperlinks and comments).

// Remove cell content.
worksheet["D3"].Value = null;

// Remove cell formatting.
worksheet["D4"].Style = workbook.Styles.DefaultStyle;

// Remove hyperlinks from cells.

Hyperlink hyperlinkD5 = worksheet.Hyperlinks.GetHyperlinks(worksheet["D5"])[0];

// Remove comments from cells.

Comment commentD6 = worksheet.Comments.GetComments(worksheet["D6"])[0];

The following code snippets (auto-collected from DevExpress Examples) contain references to the ClearComments(CellRange) method.


The algorithm used to collect these code examples remains a work in progress. Accordingly, the links and snippets below may produce inaccurate results. If you encounter an issue with code examples below, please use the feedback form on this page to report the issue.

See Also