管理工作表中的注释
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"; |
访问评论
要访问评论:
- 访问包含评论的单元格。
- 获取单元格的引用。
- 将引用传递给评论集合以访问评论。
- 现在可以修改评论的属性。
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); |