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

Questions Fréquemment Posées

Comment puis-je ajouter un commentaire à une cellule Excel en utilisant C# ?

Vous pouvez ajouter un commentaire à une cellule Excel en utilisant la bibliothèque IronXL en C#. Tout d'abord, téléchargez la bibliothèque depuis NuGet. Puis, utilisez la méthode AddComment sur l'objet cellule pour insérer un commentaire.

Comment puis-je modifier un commentaire existant dans une feuille de calcul Excel ?

Pour modifier un commentaire existant dans une feuille de calcul Excel en utilisant IronXL, accédez à la propriété Comment de la cellule. Cela vous permet de changer le contenu, l'auteur et la visibilité du commentaire.

Quel est le processus pour supprimer un commentaire d'une cellule dans Excel ?

Pour supprimer un commentaire d'une cellule dans Excel en utilisant IronXL, accédez à l'objet cellule et appelez la méthode RemoveComment sur celui-ci.

Comment puis-je enregistrer un classeur Excel après avoir modifié des commentaires ?

Après avoir ajouté ou modifié des commentaires dans un classeur Excel en utilisant IronXL, assurez-vous de sauvegarder les modifications en appelant la méthode Save sur l'objet WorkBook.

Les commentaires dans Excel peuvent-ils être invisibles par défaut ?

Oui, les commentaires dans Excel sont invisibles par défaut lorsqu'ils sont ajoutés à l'aide de IronXL. Ils deviennent visibles lorsque vous survolez la cellule.

De quoi ai-je besoin pour activer la fonctionnalité de commentaire dans Excel en utilisant C# ?

Pour activer la fonctionnalité de commentaire dans Excel en utilisant C#, téléchargez et installez la bibliothèque IronXL.Excel depuis NuGet.

L'auteur d'un commentaire peut-il être mis à jour dans Excel ?

Oui, vous pouvez mettre à jour l'auteur d'un commentaire dans Excel en accédant à l'objet Comment de la cellule et en définissant la propriété Author en utilisant IronXL.

Comment puis-je vérifier si une cellule contient un commentaire ?

Vous pouvez vérifier si une cellule contient un commentaire en utilisant la propriété HasComment de la cellule avec IronXL.

Quel langage de programmation est utilisé pour ajouter des commentaires aux feuilles Excel ?

C# est le langage de programmation utilisé avec IronXL pour ajouter des commentaires aux feuilles Excel.

Est-il possible d'annoter des feuilles de calcul Excel sans utiliser Interop ?

Oui, vous pouvez annoter des feuilles de calcul Excel sans utiliser Interop en utilisant la bibliothèque IronXL pour ajouter, modifier et supprimer des commentaires.

Chaknith Bin
Ingénieur logiciel
Chaknith travaille sur IronXL et IronBarcode. Il a une expertise approfondie en C# et .NET, aidant à améliorer le logiciel et à soutenir les clients. Ses idées issues des interactions avec les utilisateurs contribuent à de meilleurs produits, documentation et expérience globale.
Prêt à commencer?
Nuget Téléchargements 1,686,155 | Version : 2025.11 vient de sortir