管理工作表中的评论

使用注释

添加评论

要向工作表添加评论,请按照以下步骤操作:

  1. 将 Aspose.Cells.GridWeb 控件添加到 Web 窗体。
  2. 访问要添加评论的工作表。
  3. 向单元格添加注释。
  4. 为新评论设置注释。

评论已添加到工作表

待办事项:图片_替代_文本

// 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";

访问评论

要访问评论:

  1. 访问包含评论的单元格。
  2. 获取单元格的引用。
  3. 将引用传递给 Comment 集合以访问评论。
  4. 现在可以修改评论的属性。
// 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.";
}

删除评论

要删除评论:

  1. 如上所述访问单元格。
  2. 使用 Comment 集合的 RemoveAt 方法删除评论。
// 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);