スレッド型コメント

スレッド化されたコメント

MS Excel 365 では、スレッド型コメントを追加する機能が提供されています。これらのコメントは会話として機能し、ディスカッションに使用できます。新しいコメントにはスレッド型の会話が可能なリプライボックスが付属しています。古いコメントは Excel 365 ではノートと呼ばれます。以下のスクリーンショットは、Excel 365 でスレッド型コメントが開かれたときの表示例です。

todo:image_alt_text

古いバージョンの Excel では、スレッド型コメントは以下のように表示されます。以下の画像は、サンプルファイルを Excel 2016 で開いたものです。

todo:image_alt_text

todo:image_alt_text

Aspose.Cells では、スレッド型コメントの管理機能も提供されています。

スレッド型コメントの追加

Excel でスレッド型コメントを追加

Excel 365 でスレッド型コメントを追加するには、以下の手順に従ってください。

  • 方法 1
    • レビュー タブをクリック
    • 新しいコメント ボタンをクリック
    • これにより、アクティブなセルにコメントを入力するためのダイアログが開きます。
    • todo:image_alt_text
  • 方法 2
    • コメントを挿入したいセルを右クリック
    • 新しいコメント オプションをクリック
    • これにより、アクティブなセルにコメントを入力するためのダイアログが開きます。
    • todo:image_alt_text

Aspose.Cells を使用してスレッド型コメントを追加

Aspose.Cells では、スレッド型コメントを追加するための Comments.AddThreadedComment メソッドが提供されています。Comments.AddThreadedComment メソッドは、次の3つのパラメーターを受け入れます。

  • セル名: コメントを挿入するセルの名前。
  • コメントのテキスト: コメントのテキスト。
  • ThreadedCommentAuthor: コメントの作者

次のコードサンプルは、セルA1にスレッド化されたコメントを追加するためのComments.AddThreadedCommentメソッドの使用を示しています。参照のためにコードによって生成された出力エクセルファイルをご覧ください。

サンプルコード

// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET
//Source directory
string outDir = RunExamples.Get_OutputDirectory();
Workbook workbook = new Workbook();
// Add Author
int authorIndex = workbook.Worksheets.ThreadedCommentAuthors.Add("Aspose Test", "", "");
ThreadedCommentAuthor author = workbook.Worksheets.ThreadedCommentAuthors[authorIndex];
// Add Threaded Comment
workbook.Worksheets[0].Comments.AddThreadedComment("A1", "Test Threaded Comment", author);
workbook.Save(outDir + "AddThreadedComments_out.xlsx");

スレッド化されたコメントを読む

Excelでスレッド化されたコメントを読む

Excelでスレッド化されたコメントを読むには、単にコメントを含むセル上にマウスを動かすとコメントが表示されます。コメント表示は、次の画像に示すような表示になります。

todo:image_alt_text

Aspose.Cellsを使用してスレッド化されたコメントを読む

Aspose.Cellsは指定された列のスレッド化されたコメントを取得するためのComments.GetThreadedCommentsメソッドを提供します。Comments.GetThreadedCommentsメソッドは列名をパラメータとして受け取り、ThreadedCommentCollectionを返します。ThreadedCommentCollectionを繰り返し処理してコメントを表示できます。

次の例は、サンプルエクセルファイルを読み込んで列A1からコメントを読み取ることを示しています。参照のためにコードによって生成されたコンソール出力をご覧ください。

サンプルコード

// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET
//Source directory
string sourceDir = RunExamples.Get_SourceDirectory();
Workbook workbook = new Workbook(sourceDir + "ThreadedCommentsSample.xlsx");
//Access first worksheet
Worksheet worksheet = workbook.Worksheets[0];
// Get Threaded Comments
ThreadedCommentCollection threadedComments = worksheet.Comments.GetThreadedComments("A1");
foreach (ThreadedComment comment in threadedComments)
{
Console.WriteLine("Comment: " + comment.Notes);
Console.WriteLine("Author: " + comment.Author.Name);
}

コンソール出力

Comment: Test Threaded Comment

Author: Aspose Test

スレッド化されたコメントの作成時間を読む

Aspose.Cellsは指定された列のスレッド化されたコメントを取得するためのComments.GetThreadedCommentsメソッドを提供します。Comments.GetThreadedCommentsメソッドは列名をパラメータとして受け取り、ThreadedCommentCollectionを返します。ThreadedCommentCollectionを繰り返し処理し、ThreadedComment.CreatedTimeプロパティを使用できます。

次の例は、サンプルエクセルファイルを読み込んでスレッド化されたコメントの作成時間を読み取ることを示しています。参照のためにコードによって生成されたコンソール出力をご覧ください。

サンプルコード

// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET
//Source directory
string sourceDir = RunExamples.Get_SourceDirectory();
Workbook workbook = new Workbook(sourceDir + "ThreadedCommentsSample.xlsx");
//Access first worksheet
Worksheet worksheet = workbook.Worksheets[0];
// Get Threaded Comments
ThreadedCommentCollection threadedComments = worksheet.Comments.GetThreadedComments("A1");
foreach (ThreadedComment comment in threadedComments)
{
Console.WriteLine("Comment: " + comment.Notes);
Console.WriteLine("Author: " + comment.Author.Name);
Console.WriteLine("Created Time: " + comment.CreatedTime);
}

コンソール出力

Comment: Test Threaded Comment

Author: Aspose Test

Created Time: 5/15/2019 12:46:23 PM

スレッド化されたコメントの編集

Excelでスレッド化されたコメントを編集する

Excelでスレッド化されたコメントを編集するには、次の画像に示すようにコメントの編集リンクをクリックします。

todo:image_alt_text

Aspose.Cellsを使用してスレッド化されたコメントを編集する

Aspose.Cellsは指定された列のコメントを削除するためのComments.GetThreadedCommentsメソッドを提供します。Comments.GetThreadedCommentsメソッドは列名をパラメータとして受け取り、その列内のコメントを削除します。

次の例は、サンプルエクセルファイルを読み込んで列A1のコメントを削除することを示しています。参照のためにコードによって生成された更新されたコメントを示す出力エクセルファイルをご覧ください。

サンプルコード

// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET
//Source directory
string sourceDir = RunExamples.Get_SourceDirectory();
string outDir = RunExamples.Get_OutputDirectory();
Workbook workbook = new Workbook(sourceDir + "ThreadedCommentsSample.xlsx");
//Access first worksheet
Worksheet worksheet = workbook.Worksheets[0];
// Get Threaded Comment
ThreadedComment comment = worksheet.Comments.GetThreadedComments("A1")[0];
comment.Notes = "Updated Comment";
workbook.Save(outDir + "EditThreadedComments.xlsx");

スレッド化されたコメントを削除する

Excelでスレッド化されたコメントを削除する

Excelでスレッド化されたコメントを削除するには、コメントを含むセルを右クリックし、次の画像に示すようにコメントを削除オプションをクリックします。

todo:image_alt_text

Aspose.Cellsを使用してスレッド化されたコメントを削除する

Aspose.Cellsは指定された列のコメントを削除するためのComments.RemoveAtメソッドを提供します。Comments.RemoveAtメソッドは列名をパラメータとして受け取り、その列内のコメントを削除します。

次の例は、サンプルエクセルファイルを読み込んで列A1のコメントを削除することを示しています。参照のためにコードによって生成された出力エクセルファイルをご覧ください。

サンプルコード

// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET
//Source directory
string sourceDir = RunExamples.Get_SourceDirectory();
string outDir = RunExamples.Get_OutputDirectory();
Workbook workbook = new Workbook(sourceDir + "ThreadedCommentsSample.xlsx");
//Access first worksheet
Worksheet worksheet = workbook.Worksheets[0];
CommentCollection comments = worksheet.Comments;
// Get Author of first comment in A1
ThreadedCommentAuthor author = worksheet.Comments.GetThreadedComments("A1")[0].Author;
// Remove Comments
comments.RemoveAt("A1");
ThreadedCommentAuthorCollection authors = workbook.Worksheets.ThreadedCommentAuthors;
// Remove Author of first comment in A1
authors.RemoveAt(authors.IndexOf(author));
workbook.Save(outDir + "ThreadedCommentsSample_Out.xlsx");