ClearContents
Clears all contents from the current range.
Syntax
expression.ClearContents();
expression - A variable that represents a ApiRange class.
Parameters
This method doesn't have any parameters.
Returns
This method doesn't return any data.
Example
Delete the values from a cell range while keeping its formatting intact in a spreadsheet.
// How do I remove cell data without touching the styling in a spreadsheet?
// Wipe only the text and numbers from selected cells so their appearance stays unchanged in a spreadsheet.
let worksheet = Api.GetActiveSheet();
worksheet.GetRange("A1:B1").SetValue("Example text");
let range = worksheet.GetRange("A1");
range.ClearContents();
worksheet.GetRange("A2").SetValue("Result is contents cleared for A1 cell.");