How to Add Comments to Excel Documents Using C#
Live Chat Icon For mobile
Live Chat Icon
Popular Categories.NET  (175).NET Core  (29).NET MAUI  (208)Angular  (109)ASP.NET  (51)ASP.NET Core  (82)ASP.NET MVC  (89)Azure  (41)Black Friday Deal  (1)Blazor  (220)BoldSign  (15)DocIO  (24)Essential JS 2  (107)Essential Studio  (200)File Formats  (67)Flutter  (133)JavaScript  (221)Microsoft  (119)PDF  (81)Python  (1)React  (101)Streamlit  (1)Succinctly series  (131)Syncfusion  (920)TypeScript  (33)Uno Platform  (3)UWP  (4)Vue  (45)Webinar  (51)Windows Forms  (61)WinUI  (68)WPF  (159)Xamarin  (161)XlsIO  (37)Other CategoriesBarcode  (5)BI  (29)Bold BI  (8)Bold Reports  (2)Build conference  (8)Business intelligence  (55)Button  (4)C#  (151)Chart  (132)Cloud  (15)Company  (443)Dashboard  (8)Data Science  (3)Data Validation  (8)DataGrid  (63)Development  (633)Doc  (8)DockingManager  (1)eBook  (99)Enterprise  (22)Entity Framework  (5)Essential Tools  (14)Excel  (41)Extensions  (22)File Manager  (7)Gantt  (18)Gauge  (12)Git  (5)Grid  (31)HTML  (13)Installer  (2)Knockout  (2)Language  (1)LINQPad  (1)Linux  (2)M-Commerce  (1)Metro Studio  (11)Mobile  (508)Mobile MVC  (9)OLAP server  (1)Open source  (1)Orubase  (12)Partners  (21)PDF viewer  (43)Performance  (12)PHP  (2)PivotGrid  (4)Predictive Analytics  (6)Report Server  (3)Reporting  (10)Reporting / Back Office  (11)Rich Text Editor  (12)Road Map  (12)Scheduler  (52)Security  (3)SfDataGrid  (9)Silverlight  (21)Sneak Peek  (31)Solution Services  (4)Spreadsheet  (11)SQL  (11)Stock Chart  (1)Surface  (4)Tablets  (5)Theme  (12)Tips and Tricks  (112)UI  (387)Uncategorized  (68)Unix  (2)User interface  (68)Visual State Manager  (2)Visual Studio  (31)Visual Studio Code  (19)Web  (597)What's new  (333)Windows 8  (19)Windows App  (2)Windows Phone  (15)Windows Phone 7  (9)WinRT  (26)
How to Add Comments to Excel Documents Using C#

How to Add Comments to Excel Documents Using C#

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 release on, the Syncfusion Excel Library (XlsIO) supports adding threaded comments to Excel documents. With this feature, you can allow multiple users to add comments or reply to existing comments in an Excel worksheet.

Enjoy a smooth experience with Syncfusion’s Excel Library! Get started with a few lines of code and without Microsoft or interop dependencies.

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

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 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.

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.

Adding a threaded comment in an Excel document
Adding a threaded comment in an Excel document

Syncfusion’s high-performance Excel Library offers a plethora of state-of-the art features backed by comprehensive documentation.

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#

//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.

Replying to a comment in an Excel document
Replying to a comment in an Excel document

Experience Syncfusion's Excel Framework in action through interactive demos, giving you the confidence to implement it in your projects immediately.

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.

//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.

Marking a discussion as resolved in an Excel document
Marking a discussion as resolved in an Excel document

GitHub reference

You can download examples of threaded comments in Excel documents using C# from this GitHub page.

From simple data tables to complex financial models, Syncfusion empowers you to unleash your creativity and design stunning Excel spreadsheets.

Conclusion

Thanks for reading! In this blog, we’ve explored the new threaded comments feature added to the Syncfusion Excel Library (XlsIO) for the 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, where you’ll find other Excel options and features like conditional formattingtablespivot tables, and charts.

Using the Excel Library, you can export Excel data to PDFimagedata tableCSVTSVHTMLcollections of objectsODSJSON, and more file formats.

Are you already a Syncfusion user? You can download the product setup here. If you’re not a Syncfusion user yet, you can download a free 30-day trial here.

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 forumsupport portal, or feedback portal. We are always happy to assist you!

Related blogs

Tags:

Share this post:

Popular Now

Be the first to get updates

Subscribe RSS feed

Be the first to get updates

Subscribe RSS feed