Syncfusion.XlsIO.Base
Example 


AddComment Method (IRange)

Adds a comment.
Syntax
'Declaration
 
Function AddComment() As ICommentShape
'Usage
 
Dim instance As IRange
Dim value As ICommentShape
 
value = instance.AddComment()
ICommentShape AddComment()

Return Value

Returns a comment shape.
Example
The following code illustrates how to insert Comments in the Range.
using Syncfusion.XlsIO;
class Program
{
    static void Main()
    {
        using (ExcelEngine excelEngine = new ExcelEngine())
        {
            Create worksheet
            IApplication application = excelEngine.Excel;
            application.DefaultVersion = ExcelVersion.Excel2013;
            IWorkbook workbook = application.Workbooks.Create(1);
            IWorksheet sheet = workbook.Worksheets[0];
            
            // Adding comments to a cell.
            ICommentShape comment = sheet.Range["A1"].AddComment();
            comment.Text= "Comments";
            
            // Add Rich Text Comments.
            IRange range = sheet.Range["A6"];
            range.AddComment().RichText.Text = "RichText";
            IRichTextString rtf = range.Comment.RichText;
            
            // Formatting first 4 characters.
            IFont redFont = workbook.CreateFont();
            redFont.Bold = true;
            redFont.Color = ExcelKnownColors.Red;
            rtf.SetFont(0, 3, redFont);
            
            //Save and dispose
            workbook.SaveAs("Comments.xlsx");
            workbook.Close();
        }
    }
}
AssemblyVersion

Syncfusion.XlsIO.Base: 16.4460.0.40

See Also