Gérer les commentaires dans la feuille de calcul

Travailler avec des commentaires

Ajout de commentaires

Pour ajouter un commentaire à la feuille de calcul, veuillez suivre les étapes ci-dessous :

  1. Ajoutez le contrôle Aspose.Cells.GridWeb au formulaire Web.
  2. Accédez à la feuille de calcul à laquelle vous souhaitez ajouter des commentaires.
  3. Ajoutez un commentaire à une cellule.
  4. Définissez une note pour le nouveau commentaire.

Un commentaire a été ajouté à la feuille de calcul

todo:image_alt_text

// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET
// Accessing the reference of the worksheet that is currently active and add a dummy value to cell A1
GridWorksheet sheet = GridWeb1.WorkSheets[GridWeb1.ActiveSheetIndex];
sheet.Cells["A1"].PutValue("This cell has a comment added, hover to view.");
// Resize first column
sheet.Cells.SetColumnWidth(0, 140);
// Adding comment to "A1" cell of the worksheet
GridComment comment = sheet.Comments[sheet.Comments.Add("A1")];
// Setting the comment note
comment.Note = "These are my comments for the cell";

Accéder aux commentaires

Pour accéder à un commentaire :

  1. Accédez à la cellule qui contient le commentaire.
  2. Obtenez la référence de la cellule.
  3. Passez la référence à la collection de commentaires pour accéder au commentaire.
  4. Il est désormais possible de modifier les propriétés du commentaire.
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET
// Accessing the reference of the worksheet that is currently active
GridWorksheet sheet = GridWeb1.WorkSheets[GridWeb1.ActiveSheetIndex];
// Accessing a specific cell that contains comment
GridCell cell = sheet.Cells["A1"];
// Accessing the comment from the specific cell
GridComment comment = sheet.Comments[cell.Name];
if (comment != null)
{
// Modifying the comment note
comment.Note = "I have modified the comment note.";
}

Supprimer les Commentaires

Pour supprimer un commentaire :

  1. Accédez à la cellule comme expliqué ci-dessus.
  2. Utilisez la méthode RemoveAt de la collection Comment pour supprimer le commentaire.
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET
// Accessing the reference of the worksheet that is currently active
GridWorksheet sheet = GridWeb1.WorkSheets[GridWeb1.ActiveSheetIndex];
// Accessing a specific cell that contains comment
GridCell cell = sheet.Cells["A1"];
// Removing comment from the specific cell
sheet.Comments.RemoveAt(cell.Name);