Remove and Change Excel Comments in C#, VB.NET

This section will introduce a very simple solution to remove and change excel comment to better satisfy the need of deleting and modifying excel comment information. By using a .NET Excel component, the whole procedure can be realized by main two parts: remove excel comment and change excel comment.

Spire.XLS for .NET allows users to generate, read, write and modify Excel files without using MS Excel Automation. Using Spire.XLS for .NET, you can remove excel comment by calling the method:

Spire.Xls.Workbook.Worksheets[0].Comments[1].Remove();

Change excel comment by setting the Property:

Spire.Xls.Workbook.Worksheets[0].Comments[0]. Text= value;

Please view the original excel file which contains two excel comments as below picture:

Remove and Change Excel Comments

Now, please download Spire.XLS for .NET and see the key code of the task below:

Remove Excel Comment

[C#]
workbook.Worksheets[0].Comments[1].Remove()
[VB.NET]
workbook.Worksheets(0).Comments(1).Remove()

Change Excel Comment

[C#]
ExcelComment comment0 = workbook.Worksheets[0].Comments[0];
Comment0.Text = "The Sales Manager is Mishirna"
[VB.NET]
Dim comment0 As ExcelComment = workbook.Worksheets(0).Comments(0)
Comment0.Text = "The Sales Manager is Mishirna"

Friendly Reminder: workbook.Worksheets[0].Comments[0] means the first comment you insert in the first worksheet you created. So the first comment here may be not the first comment that you see in worksheet. In this Excel file, A8 is the first comment inserted in the worksheet, while A5 is the second comment.

After perform the code, please look at the effect of removing and changing excel comment task:

Remove and Change Excel Comments