ワークシート内のコメントの管理
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); |