ワークシートでのコメントの管理
Contents
[
Hide
]
MS Excel では、ユーザーがセルにコメントを追加できるコメント機能に精通している必要があります。この機能は、ユーザーがセルに値を入力しようとしているときに何らかの情報を提供する必要がある場合に役立ちます。ユーザーがマウス カーソルをコメント付きのセルに置くと、小さなポップアップ メッセージが表示され、ユーザーに情報が提供されます。 Aspose.Cells.GridDesktop を使用すると、開発者はセルにコメントを作成できます。このトピックでは、この機能の使用方法について詳しく説明します。
コメントの追加
Aspose.Cells.GridDesktop を使用してセルにコメントを追加するには、次の手順に従ってください。
- Aspose.Cells.GridDesktop コントロールを形
- 任意のアクセスワークシート
- 追加コメントコメントを追加するセル (名前または行と列番号を使用) を指定して、ワークシートに追加します。
以下のコードは、b2とb4ワークシートのセル。
This file contains hidden or 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 first worksheet of the Grid | |
Worksheet sheet = gridDesktop1.Worksheets[0]; | |
// Adding comment to "b2" cell | |
sheet.Comments.Add("b2", "Please write your name."); | |
// Adding another comment to "b4" cell using its row & column number | |
sheet.Comments.Add(3, 1, "Please write your email."); |
コメントのコレクションワークシートオブジェクトはオーバーロードを提供します追加方法。開発者は、オーバーロードされた任意のバージョンを使用できます追加特定のニーズに応じた方法。
コメントへのアクセス
ワークシート内の既存のコメントにアクセスして変更するには、開発者はコメントのコレクションワークシートコメントが挿入されるセルを指定する (セル名または行番号と列番号によるセルの位置を使用)。コメントにアクセスすると、開発者は実行時にそのテキストを変更できます。
This file contains hidden or 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 first worksheet of the Grid | |
Worksheet sheet = gridDesktop1.Worksheets[0]; | |
// Accessing a comment added to "c3" cell (specified using its row & column number) | |
Aspose.Cells.GridDesktop.Data.GridComment comment1 = sheet.Comments[3, 1]; | |
if (comment1 != null) | |
{ | |
// Modifying the text of comment | |
comment1.Text = "The 1st comment."; | |
MessageBox.Show("Comment has been modified"); | |
} | |
else | |
{ | |
MessageBox.Show("Please add comment before accessing it."); | |
} |
コメントの削除
既存のコメントを削除するには、開発者は目的のワークシートにアクセスして、削除するからのコメントコメントのコレクションワークシートコメントを含むセルを(名前または行と列番号を使用して)指定することにより。
This file contains hidden or 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 first worksheet of the Grid | |
Worksheet sheet = gridDesktop1.Worksheets[0]; | |
if (sheet.Comments[3, 1] != null) | |
{ | |
// Removing comment from "c3" cell | |
sheet.Comments.Remove(3, 1); | |
MessageBox.Show("Comment has been removed"); | |
} | |
else | |
{ | |
MessageBox.Show("Please add comment before removing it."); | |
} |