All docs
V19.2
19.2
19.1
The page you are viewing does not exist in version 19.1. This link will take you to the root page.
18.2
The page you are viewing does not exist in version 18.2. This link will take you to the root page.
18.1
The page you are viewing does not exist in version 18.1. This link will take you to the root page.
17.2
The page you are viewing does not exist in version 17.2. This link will take you to the root page.
.NET Framework 4.5.2+
.NET Framework 4.5.2+
.NET Standard 2.0+
.NET Core 3.0+
Row

Worksheet.Clear(CellRange) Method

Removes cell content, formatting, hyperlinks and comments.

Namespace: DevExpress.Spreadsheet

Assembly: DevExpress.Spreadsheet.v19.2.Core.dll

Declaration

void Clear(
    CellRange range
)
Sub Clear(
    range As CellRange
)
void Clear(
    CellRange range
)
Sub Clear(
    range As CellRange
)
void Clear(
    CellRange range
)
Sub Clear(
    range As CellRange
)

Parameters

Name Type Description
range CellRange

A CellRange object specifying the cell range to clear.

Parameters

Name Type Description
range CellRange

A CellRange object specifying the cell range to clear.

Parameters

Name Type Description
range CellRange

A CellRange object specifying the cell range to clear.

Remarks

The Clear method empties cells and clears all formatting. You can separately remove cell content, formatting, hyperlinks or comments using the Worksheet.ClearContents, Worksheet.ClearFormats, Worksheet.ClearHyperlinks or Worksheet.ClearComments methods, respectively.

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.

To delete entire cells from the worksheet, use the Worksheet.DeleteCells method (see the How to: Delete a Cell or Range of Cells example).

Examples

This example demonstrates how to clear worksheet cells.

// 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"])[0];
worksheet.Hyperlinks.Remove(hyperlinkD5);

// Remove comments from cells.
worksheet.ClearComments(worksheet["C6"]);
See Also