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

Free Support Forum - aspose.com

Clear cell contents from aspose.cells

Hi Aspose team,

I am using version and having a problem in clear cell contents of xlsb file. I am using "ClearContents" and here is the code sample which is not working.

Workbook workbook = null;
Worksheet worksheet = null;
FileStream fstream = null;
string Message = "";
string filePath = Server.MapPath("~/ExcelFile/" + fileName);
if (File.Exists(filePath))
using (fstream = new FileStream(filePath, FileMode.Open))
workbook = new Workbook(fstream);
worksheet = workbook.Worksheets[Sheetname];
worksheet.Cells.ClearContents(20, 0, 20, 0);// cell A20

Please suggest.

Thanks and Reagrds,


Thanks for your posting and using Aspose.Cells.

We have looked into your code and found, you are actually clearing A21 not A20, so please change your code into this.

worksheet.Cells.ClearContents(19, 0, 19, 0);// cell A20 – now it is ok

It should fix your issue. Let us know your feedback.

Hi Shakeel,

I have tried every cell reference( including 19,20,21 etc).It is not working.
Have you tried to replicate this issue? If not , then I can send a sample solution having the problem.
I need to dynamically search cell and clear the content. So I used the “ClearContent” method.
worksheet.Cells.ClearContents(19, 0, 19, 0);// for cell A20

Thanks and Regards,


Please try our latest version/fix: Aspose.Cells for .NET v17.4.6 (attached).

If you still find the issue, kindly do provide us template Excel file and do mentioned which worksheet cell content you are trying to clear (we also appreciate if you could create a simple console demo application (runnable) with v17.4.5, you may zip it prior attaching here with the files), we will check it soon.

Thank you.

Hi Aspose team,

It is not working on my end.I have attached the sample application file for your reference.Please look into this and let me know if there is any issue.

Thanks and Regards,


Thanks for your sample code and using Aspose.Cells.

We have looked into your web application and found, it is working good. Please see this screenshot that shows, the output of the code is good.

We found that you get an exception on Workbook.Save() method, please debug the application and resolve it at your end.

For debugging purpose, we resolved it like this and everything was good.


Hi Aspose Team,

I am able to clear the cells now and integrated code in original application is also working properly.

thanks for the help.

Thanks and Regards,

Thanks for your feedback and using Aspose.Cells.

It is good to know that you are able to sort out this issue. Let us know if you encounter any other issue, we will be glad to look into it and help you further.