Excel for WPF | ComponentOne
C1Excel Task-Based Help / Adding a Comment to a Cell (WPF)
In This Topic
    Adding a Comment to a Cell (WPF)
    In This Topic

    To add a comment to a cell, complete the following steps:

    1. Add a reference to C1.WPF.Excel.dll and create a C1XLBook.

      <// Create a new workbook C1XLBook book = new C1XLBook();

    2. Add text to a cell in the worksheet using the following code:

      book.Sheets[0][2, 3].Value = "test";

    3. Add a comment to the XLCommentCollection and create a box to show it in using the following code:

      book.Sheets[0].Comments.Add(2, 3, "John", "Test comment");
      book.Sheets[0].Comments[0].TextBox.Rectangle = new Rect(220, 210, 1900, 1200);

    4. Save and open the book:
      C#
      Copy Code
      // Save and open the file
       book.Save(@"C:\test.xlsx");
       System.Diagnostics.Process.Start(@"C:\test.xlsx");
      
    5. Run the program. The spreadsheet will open and look similar to the following:

      Add Comment