How to Add Comments to Excel Documents Using C#
Tags: fileformats, csharp, excel, whatsnew
Published: 2023-10-03 15:36:09

---
title: How to Add Comments to Excel Documents Using C#
published: true
date: 2023-09-29 11:16:29 UTC
tags: fileformats, csharp, excel, whatsnew
canonical_url: https://www.syncfusion.com/blogs/post/add-comments-in-excel-csharp.aspx
cover_image: https://dev-to-uploads.s3.amazonaws.com/uploads/articles/bjcvyuduey57w8egpgjb.png
---
Commenting is a useful feature in Excel documents that allows users to add additional information about specific cell data, calculations, and references used inside a cell. Comments serve as a form of documentation to help you and others understand the content and context of your Excel workbook. They are particularly useful when sharing workbooks with other collaborators.

From the [2023 Volume 3](https://www.syncfusion.com/forums/184588/essential-studio-2023-volume-3-main-release-v23-1-36-is-available-for-download "Essential Studio 2023 Volume 3") release on, the [Syncfusion Excel Library (XlsIO)](https://www.syncfusion.com/document-processing/excel-framework/net ".NET Excel Library") supports adding [threaded comments](https://help.syncfusion.com/file-formats/xlsio/working-with-drawing-objects#threaded-comments "Threaded comments in Excel Library") to Excel documents. With this feature, you can allow multiple users to add comments or reply to existing comments in an Excel worksheet.

You can perform the following actions with threaded-comments support in the Excel Library:

- [Create a new threaded comment](https://help.syncfusion.com/file-formats/xlsio/working-with-drawing-objects#create "Creating new comments in Excel") for a cell.
- [Reply](https://help.syncfusion.com/file-formats/xlsio/working-with-drawing-objects#reply "Reply to a threaded comment in Excel") to existing comments.
- Mark the discussion in the comments as [resolved](https://help.syncfusion.com/file-formats/xlsio/working-with-drawing-objects#mark-as-resolved "Marking a comment as resolved").

Let’s see how to perform these actions with code examples!

**Note:** If you are new to our Excel Library, following our [getting started guide](https://help.syncfusion.com/file-formats/xlsio/getting-started-create-excel-file-csharp-vbnet "Getting started with .NET Excel Library") is highly recommended.

## Add comment

A comment can be any text related to the cell information. The following code example illustrates how to add threaded comments to a cell in a worksheet.

```csharp
using (ExcelEngine excelEngine = new ExcelEngine())
{
    IApplication application = excelEngine.Excel;
    application.DefaultVersion = ExcelVersion.Xlsx;

    FileStream inputStream = new FileStream("../../../Data/CommentsTemplate.xlsx", FileMode.Open, FileAccess.Read);
    IWorkbook workbook = application.Workbooks.Open(inputStream, ExcelOpenType.Automatic);

    IWorksheet worksheet = workbook.Worksheets[0];

    //Add threaded comments.
    IThreadedComment threadedComment = worksheet.Range["H16"].AddThreadedComment("What is the reason for the higher total amount of \"desk\" in the west region?", "User1", DateTime.Now);

    FileStream stream = new FileStream("output.xlsx", FileMode.Create, FileAccess.ReadWrite);
    workbook.SaveAs(stream);
    workbook.Close();
    excelEngine.Dispose();
}
```

This results in the following image.
<figure>

  <img src="https://www.syncfusion.com/blogs/wp-content/uploads/2023/09/Adding-a-threaded-comment-in-an-Excel-document.png" alt="Adding a threaded comment in an Excel document" style="width:100%">

  <figcaption>Adding a threaded comment in an Excel document</figcaption>

</figure>

## Reply to comment

You can add a reply to an existing comment in an Excel document. The following code example illustrates how to add a reply to a comment using C#

```csharp
//Add threaded comments.
IThreadedComment threadedComment = worksheet.Range["H16"].AddThreadedComment("What is the reason for the higher total amount of \"desk\" in the west region?", "User1", DateTime.Now);
                
//Add reply to the threaded comment.
threadedComment.AddReply("The unit cost of desk is higher compared to other items in the west region. As a result, the total amount is elevated.", "User2", DateTime.Now);
```

Refer to the following image.
<figure>

  <img src="https://www.syncfusion.com/blogs/wp-content/uploads/2023/09/Replying-to-a-comment-in-an-Excel-document.png" alt="Replying to a comment in an Excel document" style="width:100%">

  <figcaption>Replying to a comment in an Excel document</figcaption>

</figure>

## Mark as resolved

You can also mark a discussion (comments) created for a cell as resolved. This way, other users know to ignore the discussion.

The following code example illustrates how to mark a discussion as resolved.

```csharp
//Add threaded comments.
IThreadedComment threadedComment = worksheet.Range["H16"].AddThreadedComment("What is the reason for the higher total amount of \"desk\" in the west region?", "User1", DateTime.Now);
                
//Add reply to the threaded comment.
threadedComment.AddReply("The unit cost of desk is higher compared to other items in the west region. As a result, the total amount is elevated.", "User2", DateTime.Now);

//Mark as resolved.
threadedComment.IsResolved = true;
```

Refer to the following image.
<figure>

  <img src="https://www.syncfusion.com/blogs/wp-content/uploads/2023/09/Marking-a-discussion-as-resolved-in-an-Excel-document.png" alt="Marking a discussion as resolved in an Excel document" style="width:100%">

  <figcaption>Marking a discussion as resolved in an Excel document</figcaption>

</figure>

## GitHub reference

You can download examples of [threaded comments in Excel documents using C# from this GitHub page](https://github.com/SyncfusionExamples/XlsIO-Examples/tree/master/Threaded%20Comments "Threaded comments in Excel GitHub demos").

## Conclusion

Thanks for reading! In this blog, we’ve explored the new [threaded comments](https://help.syncfusion.com/file-formats/xlsio/working-with-drawing-objects#threaded-comments "Threaded comments in Excel") feature added to the [Syncfusion Excel Library (XlsIO)](https://www.syncfusion.com/excel-framework/net ".NET Excel Library") for the [2023 Volume 3](https://www.syncfusion.com/forums/184588/essential-studio-2023-volume-3-main-release-v23-1-36-is-available-for-download "Essential Studio 2023 Volume 3")  release. This feature is useful for collaborating on Excel documents and getting feedback from others.

Take a moment to peruse the [documentation](https://help.syncfusion.com/file-formats/xlsio/working-with-data#importing-data-to-worksheets "Working with Excel data"), where you’ll find other Excel options and features like [conditional formatting](https://help.syncfusion.com/file-formats/xlsio/working-with-conditional-formatting "Conditional formatting in Excel"), [tables](https://help.syncfusion.com/file-formats/xlsio/working-with-excel-tables "Tables in Excel"), [pivot tables](https://help.syncfusion.com/file-formats/xlsio/working-with-pivot-tables "Pivot tables in Excel"), and [charts](https://help.syncfusion.com/file-formats/xlsio/working-with-charts "Charts in Excel").

Using the Excel Library, you can export Excel data to [PDF](https://help.syncfusion.com/file-formats/xlsio/excel-to-pdf-conversion "Convert Excel to PDF"), [image](https://help.syncfusion.com/file-formats/xlsio/worksheet-to-image-conversion "Worksheet to image conversion"), [data table](https://help.syncfusion.com/file-formats/xlsio/working-with-data#exporting-from-worksheet-to-data-table "Exporting from Worksheet to Data Table"), [CSV](https://www.syncfusion.com/kb/9092/convert-excel-file-to-csv-in-c-vb-net "Convert Excel file to CSV"), [TSV](https://www.syncfusion.com/kb/8556/does-xlsio-support-tsv-files "Convert Excel to TSV"), [HTML](https://help.syncfusion.com/file-formats/xlsio/working-with-excel-worksheet#save-worksheet-as-html "Save Worksheet as HTML"), [collections of objects](https://help.syncfusion.com/file-formats/xlsio/working-with-data#exporting-from-worksheet-to-clr-objects "Working with Excel data"), [ODS](https://help.syncfusion.com/file-formats/xlsio/excel-to-ods-conversion "Convert Excel to ODS"), [JSON](https://help.syncfusion.com/file-formats/xlsio/excel-to-json-conversion "Convert Excel to JSON"), and more file formats.

Are you already a Syncfusion user? You can download the product setup [here](https://www.syncfusion.com/account/downloads/studio/ "Essential Studio Licences and Downloads page"). If you’re not a Syncfusion user yet, you can download a free 30-day trial [here](https://www.syncfusion.com/downloads/fileformats/confirm "Get free evaluation of the Essential Studio products").

Please let us know in the comments section below if you have any questions about these features. You can also contact us through our [support forum](https://www.syncfusion.com/forums "Syncfusion Support Forum"), [support portal](https://support.syncfusion.com/ "Syncfusion Support Portal"), or [feedback portal](https://www.syncfusion.com/feedback/excel "Syncfusion Feedback Portal"). We are always happy to assist you!

## Related blogs

- [Easiest Ways to Highlight Data in Excel Using C#](https://blog.syncfusion.com/blogs/post/highlight-data-in-excel-using-csharp.aspx "Blog: Easiest Ways to Highlight Data in Excel Using C#")
- [6 Easy Ways to Export Data to Excel in C#](https://www.syncfusion.com/blogs/post/6-easy-ways-to-export-data-to-excel-in-c-sharp.aspx "Blog: 6 Easy Ways to Export Data to Excel in C#")
- [Export Data from Collection to Excel and Group It in C#](https://www.syncfusion.com/blogs/post/export-data-from-collection-to-excel-and-group-csharp.aspx "Blog: Export Data from Collection to Excel and Group It in C#")
- [Export Data to a Predefined Excel Template in C#](https://www.syncfusion.com/blogs/post/export-data-to-a-predefined-excel-template-in-c.aspx "Blog: Export Data to a Predefined Excel Template in C#")
- [Easy Steps to Export HTML Tables to an Excel Worksheet in C#](https://www.syncfusion.com/blogs/post/easy-steps-to-export-html-tables-to-an-excel-worksheet-in-c.aspx "Blog: Easy Steps to Export HTML Tables to an Excel Worksheet in C#")