NativeExcel2 for .Net Developer's Reference

IRange.ClearContentsMethod

Clears the data from the range but leaves the formatting.

[Visual Basic]
SubClearContents()
[C#]
voidClearContents();
[C++]
voidClearContents();
[JScript]
functionClearContents();

Example

This example clears the data from cells A1:G37 on sheet one but leaves the formatting intact.

[C#]
 book.Worksheets[1].Range["A1:G37"].ClearContents(); 
[VisualBasic]
 book.Worksheets(1).Range("A1:G37").ClearContents()
[C++]
 book->Worksheets->Item[1]->Range->Item[S"A1:G37"]->ClearContents(); 

See Also

IRange Interface | NativeExcel Namespace | Clear Method