Category / Section
How to format comments in a cell using XlsIO
1 min read
Comments in a cell can be formatted using ‘IRichTextString’. Here is the sample code for
formatting the comments in a cell using XlsIO.
C#
IRange range = worksheet.Range["A1"];
string commentText = "Hello World";
//Adding RichText comment to cell
range.AddComment().RichText.Text = commentText;
IRichTextString rtf = range.Comment.RichText;
//Formatting the comment
IFont font = workbook.CreateFont();
font.Italic = true;
font.Size = 15;
rtf.SetFont(0, commentText.Length, font);
VB
Dim range As IRange = worksheet.Range("A1")
Dim commentText As String = "Hello World"
'Adding RichText comment to cell
range.AddComment().RichText.Text = commentText
Dim rtf As IRichTextString = range.Comment.RichText
'Formatting the comment
Dim font As IFont = workbook.CreateFont()
font.Italic = True
font.Size = 15
rtf.SetFont(0, commentText.Length, font)
The sample illustrating this behavior can be downloaded here.
Did not find the solution
Contact Support