How to add Comment

This article was translated from English: Does it need improvement?
Translated
View the article in English

In Excel, a comment is a note or annotation that can be added to a cell to provide additional information without affecting the actual content of the cell. Comments are useful for providing explanations, context, or reminders about the data or calculations within a specific cell.

Quickstart: Add a Comment to a Cell in One Simple Line

This code shows how easily you can add a comment to a specific Excel cell using IronXL—with a single method call. No interop, no fuss—just call AddComment on a cell and you're done.

Nuget IconGet started making PDFs with NuGet now:

  1. Install IronXL with NuGet Package Manager

    PM > Install-Package IronXL.Excel

  2. Copy and run this code snippet.

    IronXL.WorkBook.Create().DefaultWorkSheet["B2"].First().AddComment("Quick tip!", "Dev");
  3. Deploy to test on your live environment

    Start using IronXL in your project today with a free trial
    arrow pointer


Add Comment Example

Select the cell and use the AddComment method to add a comment to the cell. By default, the comment will be invisible. Hover on the cell to see the comment.

:path=/static-assets/excel/content-code-examples/how-to/add-comment-add-comment.cs
using IronXL;
using System.Linq;

WorkBook workBook = WorkBook.Create();
WorkSheet workSheet = workBook.DefaultWorkSheet;

Cell cellA1 = workSheet["A1"].First();
Cell cellD1 = workSheet["D1"].First();

// Add comments
cellA1.AddComment("Hello World!", "John Doe"); // Add comment with content and author. The comment is invisible by default.
cellD1.AddComment(null, null, true); // Add comment with no content and no author. The comment is set to be visible.

workBook.SaveAs("addComment.xlsx");
Imports IronXL
Imports System.Linq

Private workBook As WorkBook = WorkBook.Create()
Private workSheet As WorkSheet = workBook.DefaultWorkSheet

Private cellA1 As Cell = workSheet("A1").First()
Private cellD1 As Cell = workSheet("D1").First()

' Add comments
cellA1.AddComment("Hello World!", "John Doe") ' Add comment with content and author. The comment is invisible by default.
cellD1.AddComment(Nothing, Nothing, True) ' Add comment with no content and no author. The comment is set to be visible.

workBook.SaveAs("addComment.xlsx")
$vbLabelText   $csharpLabel

Edit Comment Example

Access the Comment property of the cell to retrieve the Comment object for the cell. This is the object you can use to change the Author, Content, and visibility.

:path=/static-assets/excel/content-code-examples/how-to/add-comment-edit-comment.cs
using IronXL;
using System.Linq;

WorkBook workBook = WorkBook.Load("addComment.xlsx");
WorkSheet workSheet = workBook.DefaultWorkSheet;

Cell cellA1 = workSheet["A1"].First();

// Retrieve comment
var comment = cellA1.Comment;

// Edit comment
comment.Author = "Jane Doe";
comment.Content = "Bye World";
comment.IsVisible = true;

workBook.SaveAs("editComment.xlsx");
Imports IronXL
Imports System.Linq

Private workBook As WorkBook = WorkBook.Load("addComment.xlsx")
Private workSheet As WorkSheet = workBook.DefaultWorkSheet

Private cellA1 As Cell = workSheet("A1").First()

' Retrieve comment
Private comment = cellA1.Comment

' Edit comment
comment.Author = "Jane Doe"
comment.Content = "Bye World"
comment.IsVisible = True

workBook.SaveAs("editComment.xlsx")
$vbLabelText   $csharpLabel

Remove Comment Example

Remove a comment from a cell by first accessing the cell object. Then, call the RemoveComment method on the cell.

:path=/static-assets/excel/content-code-examples/how-to/add-comment-remove-comment.cs
using IronXL;
using System.Linq;

WorkBook workBook = WorkBook.Load("addComment.xlsx");
WorkSheet workSheet = workBook.DefaultWorkSheet;

Cell cellA1 = workSheet["A1"].First();

// Remove comment
cellA1.RemoveComment();

workBook.SaveAs("removeComment.xlsx");
Imports IronXL
Imports System.Linq

Private workBook As WorkBook = WorkBook.Load("addComment.xlsx")
Private workSheet As WorkSheet = workBook.DefaultWorkSheet

Private cellA1 As Cell = workSheet("A1").First()

' Remove comment
cellA1.RemoveComment()

workBook.SaveAs("removeComment.xlsx")
$vbLabelText   $csharpLabel

Preguntas Frecuentes

¿Cómo puedo agregar un comentario en una celda de Excel usando C#?

Puedes agregar un comentario a una celda de Excel utilizando la biblioteca IronXL en C#. Primero, descarga la biblioteca desde NuGet. Luego, usa el método AddComment en el objeto de la celda para insertar un comentario.

¿Cómo edito un comentario existente en una hoja de cálculo de Excel?

Para editar un comentario existente en una hoja de cálculo de Excel usando IronXL, accede a la propiedad Comment de la celda. Esto te permite cambiar el contenido, autor y visibilidad del comentario.

¿Cuál es el proceso para eliminar un comentario de una celda en Excel?

Para eliminar un comentario de una celda en Excel usando IronXL, accede al objeto de la celda y llama al método RemoveComment en él.

¿Cómo guardo un libro de Excel después de realizar cambios en los comentarios?

Después de agregar o editar comentarios en un libro de Excel usando IronXL, asegúrate de guardar los cambios llamando al método Save en el objeto WorkBook.

¿Pueden los comentarios en Excel ser invisibles por defecto?

Sí, los comentarios en Excel son invisibles por defecto cuando se agregan usando IronXL. Se hacen visibles al pasar el cursor sobre la celda.

¿Qué necesito para habilitar la funcionalidad de comentarios en Excel usando C#?

Para habilitar la funcionalidad de comentarios en Excel usando C#, descarga e instala la biblioteca IronXL.Excel desde NuGet.

¿Puede actualizarse el autor de un comentario en Excel?

Sí, puedes actualizar el autor de un comentario en Excel accediendo al objeto Comment de la celda y configurando la propiedad Author usando IronXL.

¿Cómo puedo verificar si una celda contiene un comentario?

Puedes verificar si una celda contiene un comentario usando la propiedad HasComment de la celda con IronXL.

¿Qué lenguaje de programación se utiliza para agregar comentarios a las hojas de Excel?

C# es el lenguaje de programación usado con IronXL para agregar comentarios a las hojas de Excel.

¿Es posible anotar hojas de cálculo de Excel sin usar Interop?

Sí, puedes anotar hojas de cálculo de Excel sin usar Interop utilizando la biblioteca de IronXL para agregar, editar y eliminar comentarios.

Chaknith Bin
Ingeniero de Software
Chaknith trabaja en IronXL e IronBarcode. Tiene un profundo conocimiento en C# y .NET, ayudando a mejorar el software y apoyar a los clientes. Sus conocimientos derivados de las interacciones con los usuarios contribuyen a mejores productos, documentación y experiencia en general.
¿Listo para empezar?
Nuget Descargas 1,686,155 | Versión: 2025.11 recién lanzado