Suggested video - EPPLUS Library - Beginners Guide Part-8
Suggested video - EPPLUS Library - Beginners Guide Part-9(A)
Suggested video - EPPLUS Library - Beginners Guide Part-10(B)
Suggested video - EPPLUS Library - Beginners Guide Part-11(C)
Suggested video - EPPLUS Library - Beginners Guide Part-12(D)
Source Code - Click to download [673 KB]
Different types of Format for Excel Comment?
Suggested video - EPPLUS Library - Beginners Guide Part-9(A)
Suggested video - EPPLUS Library - Beginners Guide Part-10(B)
Suggested video - EPPLUS Library - Beginners Guide Part-11(C)
Suggested video - EPPLUS Library - Beginners Guide Part-12(D)
Source Code - Click to download [673 KB]
Different types of Format for Excel Comment?
- Add. Move, Hide & Remove Comment to an Excel Sheet cell (We already discussed in Part 8)
- Resize/Auto fit of Comment. (We already discussed in Part 9(A))
- Add Text a Background Color in Comment. (We already discussed in Part 9(A))
- Set Text Alignments in Comment. (We already discussed in Part 10(B))
- Set Font Style in Excel Comment (We already discussed in Part 10(B))
- Add Rich Text in Excel Comment. (We already discussed in Part 11(C))
- Add Multiple Rich Text in Excel Comment. (We already discussed in Part 11(C))
- Remove Rich Text in Excel Comment. (We already discussed in Part 11(C))
- Multi Style Excel Cell & Comment Text using ExcelRichTextCollection Class. (We already discussed in Part 12(D))
- Set Line/Border Style in a Comment.
We need to attach one more namespace OfficeOpenXml.Drawing.Vml, because in this code we can see LineWidth, LineColor, LineStyle properties. These properties belong to ExcelVmlDrawingComment class & ExcelComment class is inherited from
ExcelVmlDrawingComment class so, that's why the object of ExcelComment class gets those properties from his base class.
Please see this below code.
- using(ExcelRange Rng = wsSheet1.Cells["B15"]) {
- ExcelComment cmd = Rng.AddComment("Comment Text", "Rajdip");
- cmd.Font.Bold = true;
- cmd.Font.Color = Color.Blue;
- //Apply Line or Border Style in Excel Comment.
- cmd.LineWidth = 3;
- Color GreenHexCode = ColorTranslator.FromHtml("#008000");
- cmd.LineColor = GreenHexCode; //Color.Green;
- cmd.LineStyle = eLineStyleVml.DashDot;
- cmd.Visible = true;
- }
- FromHtml (string htmlColor),
- FromOle (int oleColor),
- FromWin32 (int win32Color).
There is another enum eLineStyleVml is used in this above code. This enum has eight enumerator list. These are

Here, I am using DashDot, that means 4 within enumerator list.
The output of Code,

Full Source Code
- using OfficeOpenXml;
- using System.IO;
- using System.Drawing;
- using OfficeOpenXml.Drawing.Vml;
- namespace EpplusDemo {
- class Program {
- static void Main(string[] args) {
- //Code download from: https://everyday-be-coding.blogspot.in/p/epplus-library-part-13.html
- //Author: Rajdip Sarkar.
- //Date : 29th July 2017.
- //My YouTube Channel Link : https://www.youtube.com/channel/UCpGuQx5rDbWnc7i_qKDTRSQ
- ExcelPackage ExcelPkg = new ExcelPackage();
- ExcelWorksheet wsSheet1 = ExcelPkg.Workbook.Worksheets.Add("Sheet1");
- using(ExcelRange Rng = wsSheet1.Cells[2, 2, 2, 2]) {
- Rng.Value = "Everyday Be Coding - Excel COMMENTS Formatting using EPPlus .Net Library - Part 13(E)";
- Rng.Style.Font.Size = 16;
- Rng.Style.Font.Bold = true;
- Rng.Style.Font.Italic = true;
- }
- using(ExcelRange Rng = wsSheet1.Cells["B5"]) {
- Rng.Style.Font.Size = 20;
- Rng.Value = "Excel Comment Border Style";
- ExcelComment cmd = Rng.AddComment("Comment Text", "Rajdip");
- cmd.Font.Bold = true;
- cmd.Font.Color = Color.Blue;
- //Apply Line or Border Style in Excel Comment.
- cmd.LineWidth = 3;
- Color GreenHexCode = ColorTranslator.FromHtml("#008000");
- cmd.LineColor = GreenHexCode; //Color.Green;
- cmd.LineStyle = eLineStyleVml.DashDot;
- cmd.Visible = true;
- }
- wsSheet1.Cells[wsSheet1.Dimension.Address].AutoFitColumns();
- ExcelPkg.SaveAs(new FileInfo(@ "D:\FormatComments.xlsx"));
- }
- }
- }
Thank you for reading this article.

Join the conversation! Your thoughts help the community grow.