.NET Excel Examples
Add Comments in Excel Files with the Syncfusion .NET Excel Library
Overview
The Syncfusion® .NET Excel Library (XlsIO) enables you to create, read, and edit Excel documents programmatically without Microsoft Excel or interop dependencies. One of main features of this library is the ability to add threaded comments to a worksheet using C#.
Watch this video to see how to add comments in Excel files using the Syncfusion .NET Excel Library:
Add comments in Excel files
Follow these steps to add comments in Excel files using the Syncfusion .NET Excel Library.
Step 1: Create a new project
Start by creating a new C# Console Application project.
Step 2: Install the NuGet package
Add the Syncfusion.XlsIO.Net.Core package to your project from NuGet.org.
Step 3: Include namespaces
Add the following namespaces to your Program.cs file:
using System;
using System.IO;
using Syncfusion.XlsIO;Step 4: Add code to add comments in Excel files
Use the following code in Program.cs to add threaded comments in Excel files.
using (ExcelEngine excelEngine = new ExcelEngine())
{
IApplication application = excelEngine.Excel;
application.DefaultVersion = ExcelVersion.Xlsx;
FileStream inputStream = new FileStream(Path.GetFullPath(@"Data/CommentsTemplate.xlsx"), FileMode.Open, FileAccess.Read);
IWorkbook workbook = application.Workbooks.Open(inputStream, ExcelOpenType.Automatic);
IWorksheet worksheet = workbook.Worksheets[0];
//Add threaded comment.
IThreadedComment threadedComment = worksheet.Range["H16"].AddThreadedComment("What is the reason for the higher total amount of \"desk\" in the west region?", "User1", DateTime.Now);
#region Save
//Saving the workbook.
FileStream outputStream = new FileStream(Path.GetFullPath(@"Output/AddComment.xlsx"), FileMode.Create, FileAccess.Write);
workbook.SaveAs(outputStream);
#endregion
//Dispose streams.
outputStream.Dispose();
inputStream.Dispose();
}GitHub project
NuGet installation
Get started quickly by downloading the installer and checking license information on the Downloads page.
Table of contents
Explore these resources for comprehensive guides, knowledge base articles, insightful blogs, and ebooks.
Learning
Technical support
