alexa
menu

MAUI

  • User Guide
  • Demos
  • Support
  • Forums
  • Download
Search Results for

    Show / Hide Table of Contents

    Interface IComments

    A collection of cell comments. Each comment is represented by a Comment object.

    Inherited Members
    IEnumerable.GetEnumerator()
    Namespace: Syncfusion.XlsIO
    Assembly: Syncfusion.XlsIO.NET.dll
    Syntax
    public interface IComments : IEnumerable

    Properties

    Application

    Used without an object qualifier, this property returns an Application object that represents the Microsoft Excel application.

    Declaration
    IApplication Application { get; }
    Property Value
    Type
    IApplication
    Examples

    The following code illustrates how to access the IApplication from the IComments collection.

            using (ExcelEngine excelEngine = new ExcelEngine())
            {
                //Create worksheet
                IApplication application = excelEngine.Excel;
                application.DefaultVersion = ExcelVersion.Excel2013;
                IWorkbook workbook = application.Workbooks.Create(1);
                IWorksheet worksheet = workbook.Worksheets[0];
    
                //Add comment
                ICommentShape comment = worksheet["C2"].AddComment();
    
                //Access application object
                Console.Write(comment.Application.DefaultVersion);
    
                //Save and dispose
                workbook.SaveAs("Comments.xlsx");
                workbook.Close();
                Console.ReadKey();
            }
    //Output will be
    //Excel2013

    Count

    Returns the number of ICommentShape objects in the IComments collection. Read-only Long.

    Declaration
    int Count { get; }
    Property Value
    Type
    int
    Examples

    The following code illustrates how to access the Count property.

    using (ExcelEngine excelEngine = new ExcelEngine())
    {
        //Create worksheet
        IApplication application = excelEngine.Excel;
        application.DefaultVersion = ExcelVersion.Excel2013;
        IWorkbook workbook = application.Workbooks.Create(1);
        IWorksheet worksheet = workbook.Worksheets[0];
    
        //Add comment
        worksheet["C2"].AddComment();
        worksheet["E2"].AddComment();
    
        //Get count
        Console.Write(worksheet.Comments.Count);
    
        //Save and dispose
        workbook.SaveAs("Comments.xlsx");
        workbook.Close();
        Console.ReadKey();
    }
    //Output will be
    //2

    this[int]

    Returns a single ICommentShape object from the IComments collection.

    Declaration
    ICommentShape this[int Index] { get; }
    Parameters
    Type Name Description
    int Index
    Property Value
    Type
    ICommentShape
    Examples

    The following code illustrates how to access a ICommentShape from the IComments collection.

    using (ExcelEngine excelEngine = new ExcelEngine())
    {
        //Create worksheet
        IApplication application = excelEngine.Excel;
        application.DefaultVersion = ExcelVersion.Excel2013;
        IWorkbook workbook = application.Workbooks.Create(1);
        IWorksheet worksheet = workbook.Worksheets[0];
    
        //Add comment
        worksheet["C2"].AddComment();
    
        //Set text
        worksheet.Comments[0].Text = "Comment";
    
        //Save and dispose
        workbook.SaveAs("Comments.xlsx");
        workbook.Close();
    }

    this[int, int]

    Returns single ICommentShape object from the IComments collection by row and column one-based indexes. Read-only.

    Declaration
    ICommentShape this[int iRow, int iColumn] { get; }
    Parameters
    Type Name Description
    int iRow
    int iColumn
    Property Value
    Type
    ICommentShape
    Examples

    The following code illustrates how to access a ICommentShape from the IComments collection.

    using (ExcelEngine excelEngine = new ExcelEngine())
    {
        //Create worksheet
        IApplication application = excelEngine.Excel;
        application.DefaultVersion = ExcelVersion.Excel2013;
        IWorkbook workbook = application.Workbooks.Create(1);
        IWorksheet worksheet = workbook.Worksheets[0];
    
        //Add comment
        worksheet["C2"].AddComment();
    
        //Set text
        worksheet.Comments[2, 3].Text = "Comment";
    
        //Save and dispose
        workbook.SaveAs("Comments.xlsx");
        workbook.Close();
    }

    this[string]

    Gets single ICommentShape from the IComments collection.

    Declaration
    ICommentShape this[string name] { get; }
    Parameters
    Type Name Description
    string name

    Name of the item to get.

    Property Value
    Type Description
    ICommentShape

    Single item from the collection.

    Examples

    The following code illustrates how to access a ICommentShape from the IComments collection.

    using (ExcelEngine excelEngine = new ExcelEngine())
    {
        //Create worksheet
        IApplication application = excelEngine.Excel;
        application.DefaultVersion = ExcelVersion.Excel2013;
        IWorkbook workbook = application.Workbooks.Create(1);
        IWorksheet worksheet = workbook.Worksheets[0];
    
        //Add comment
        ICommentShape comment = worksheet["C2"].AddComment();
    
        //Set name
        comment.Name = "Comment1";
    
        //Set text
        worksheet.Comments["Comment1"].Text = "Comment";
    
        //Save and dispose
        workbook.SaveAs("Comments.xlsx");
        workbook.Close();
    }

    Parent

    Returns the parent object for the specified object.

    Declaration
    object Parent { get; }
    Property Value
    Type
    object
    Examples

    The following code illustrates how to access the parent of the IComments collection.

    using (ExcelEngine excelEngine = new ExcelEngine())
    {
        //Create worksheet
        IApplication application = excelEngine.Excel;
        application.DefaultVersion = ExcelVersion.Excel2013;
        IWorkbook workbook = application.Workbooks.Create(1);
        IWorksheet worksheet = workbook.Worksheets[0];
    
        //Add comment
        ICommentShape comment = worksheet["C2"].AddComment();
    
        //Access parent object
        Console.Write(comment.Parent.ToString());
    
        //Save and dispose
        workbook.SaveAs("Comments.xlsx");
        workbook.Close();
        Console.ReadKey();
    }
    //Output will be
    //Syncfusion.XlsIO.Implementation.Collections.ShapesCollection

    Methods

    Clear()

    Remove all ICommentShape from the IComments collection.

    Declaration
    void Clear()
    Examples

    The following code illustrates how to remove all the ICommentShape in the IComments collection.

    using (ExcelEngine excelEngine = new ExcelEngine())
    {
        //Create worksheet
        IApplication application = excelEngine.Excel;
        application.DefaultVersion = ExcelVersion.Excel2013;
        IWorkbook workbook = application.Workbooks.Create(1);
        IWorksheet worksheet = workbook.Worksheets[0];
    
        //Add comment
        worksheet["C2"].AddComment();
        worksheet["E2"].AddComment();
    
        //Add text
        worksheet.Comments[0].Text = "Comment1";
        worksheet.Comments[1].Text = "Comment2";
    
        //Clear comments
        worksheet.Comments.Clear();
    
        //Save and dispose
        workbook.SaveAs("Comments.xlsx");
        workbook.Close();
    }
    In this article
    Back to top Generated by DocFX
    Copyright © 2001 - 2026 Syncfusion Inc. All Rights Reserved