In this tutorial, we will learn step by step Excel Sheet development, using EPPlus .NET library and C#.
EPPLUS Library downlod Link - http://epplus.codeplex.com/
First of all, if we want to add comments to an Excel sheet using EPPlus, we need to know the comments.
Comments
First of all, if we want to add comments to an Excel sheet using EPPlus, we need to know the comments.
Comments
- Basically, Comments are notes that can be inserted into any Cell in Excel. Comments are very useful for reminders & notes for others subject.
- When a cell has a comment, a red indicator appears in the corner of the cell, and at the mouse hover, the comment appears.

- Add a comment.
- Move a comment box.
- Display or hide comments and their indicators.
- Delete a comment.
- Format a comment. (We will be discuss on this topic in Part-9 of this video series)
There are two ways to create Comments in Excel sheet.
- Option 1 - Using AddComment() method of ExcelRange class.
- Option 2 - Using Add() method of ExcelCommentCollection class and assigning it to the Comments property of ExcelWorksheet class.
Using AddComment() method of ExcelRange class.
- ExcelRange Rng = wsSheet1.Cells["B5"];
- Rng.Value = "Everyday Be Coding";
- ExcelComment cmd = Rng.AddComment("Comment Text", "Rajdip");
In the above example, we can see that AddComment() method of ExcelRange class accepts two strings as parameter - Text and Author. Then, it is assigned by ExcelComment class object cmd. Here, ExcelComment class can control this comment's behavior.
Option 2
Using Add() method of ExcelCommentCollection class.
In the above example, we can see that Add() method of ExcelCommentCollection class accepts three things as parameter - object of ExcelRange class, string Text, and string Author. It is assigned by ExcelComment class object cmd. Here, ExcelComment class can control this comment's behavior.
Move Comments Box in Excel Sheet
Class ExcelComment object is cmd. This class is inherited form ExcelVmlDrawingComment class & it has two properties - From & To. Class ExcelComment access From & To property from base class. These From, To properties are type of ExcelVmlDrawingPosition class. The ExcelVmlDrawingPosition class has two integer type properties - Column & Row. We are assigning it to specific row and column for moving comment box in Excel worksheet.
Note - The integer value of row and columns are zero index based.
Display and hide comments and their indicators,
ExcelComment has Visible property, It accepts bool value for deciding if the comment is displayed or not.
Delete Comments in Excel Sheet
ExcelWorkSheet class has a property Comments, and it has a Remove() method. This method accepts ExcelComment object as a parameter for deleting the comment in Excel sheet.
Output in Excel Sheet

Option 2
Using Add() method of ExcelCommentCollection class.
- ExcelRange Rng = wsSheet1.Cells["B10"];
- Rng.Value = "https://everyday-be-coding.blogspot.in/";
- ExcelComment cmd = wsSheet1.Comments.Add(Rng, "Comment Text","Rajdip");
Move Comments Box in Excel Sheet
- ExcelRange Rng = wsSheet1.Cells["B5"]
- Rng.Value = "Everyday Be Coding";
- ExcelComment cmd = Rng.AddComment("Comment Text", "Rajdip");
- cmd.From.Column = 1; //Zero Index base
- cmd.To.Column = 2;
- cmd.From.Row = 12;
- cmd.To.Row = 14;
Note - The integer value of row and columns are zero index based.
Display and hide comments and their indicators,
- ExcelRange Rng = wsSheet1.Cells["B5"];
- Rng.Value = "Everyday Be Coding";
- ExcelComment cmd = Rng.AddComment("Comment Text", "Rajdip");
- cmd.Visible = true;
Delete Comments in Excel Sheet
- ExcelRange Rng = wsSheet1.Cells["B10"];
- ExcelComment cmd = wsSheet1.Cells["B10"].Comment;
- wsSheet1.Comments.Remove(cmd);
Output in Excel Sheet


Join the conversation! Your thoughts help the community grow.