We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Clearing a whole range

I have a need of clearing a whole range of values and sometimes of their formatting. In excel I am able to do it using the range class, and applying the clearcontents. Is there an equivalent way of doing this in aspose.excel? Range object does not have any methods I could see that can do this, nor does cells object.

Hi,

Thanks for your consideration.

Now you can use Cell.PutValue(null) to clear content of a cell. I will add two methods to clear contents and formatting of a range of cells.

Cells.Clear(…) //Clear contents and formatting of a range
Cells.ClearContents(…) //Clear contents of a range

This feature will be available before the end of next week. Thanks for your waiting.

Hi,

Please download hotfix 1.8.7.

This feature is available. You can refer to https://forum.aspose.com/t/119368 for the usage.

@tdelic,
Aspose.Cells has replaced the older product Aspose.Excel which is deprecated now. You can perform all the tasks using Aspose.Cells which were offered by Aspose.Excel and also avail the latest features which are supported by all latest versions of MS Excel. You can clear the contents of a range using this latest version as follows:

var workbook = new Workbook(@"rangecells.xlsx");
var sheet = workbook.Worksheets[0];
var cells = workbook.Worksheets[0].Cells;
var range = sheet.Cells.MaxDisplayRange;
sheet.Cells.ClearContents(range.FirstRow, range.FirstColumn, range.RowCount, range.ColumnCount);
workbook.Save(@"output.xlsx");

You may check other features provided by Cells Helper class here:
Cells Helper

Get the latest version of this product here:
Aspose.Cells for .NET (Latest Version)

A working solution for testing all the features of this product is available here.