管理工作表中的评论
Contents
[
Hide
]
本主题讨论在工作表中添加、访问和删除注释。注释对于为将使用工作表的用户添加注释或有用信息很有用。开发人员可以灵活地向工作表的任何单元格添加注释。
使用注释
添加评论
要向工作表添加评论,请按照以下步骤操作:
- 将 Aspose.Cells.GridWeb 控件添加到 Web 窗体。
- 访问要添加评论的工作表。
- 向单元格添加注释。
- 为新评论设置注释。
评论已添加到工作表
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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"; |
访问评论
要访问评论:
- 访问包含评论的单元格。
- 获取单元格的引用。
- 将引用传递给 Comment 集合以访问评论。
- 现在可以修改评论的属性。
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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."; | |
} |
删除评论
要删除评论:
- 如上所述访问单元格。
- 使用 Comment 集合的 RemoveAt 方法删除评论。
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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); |