Articles in this section
Category / Section

How to resize comment box using C#,VB.NET?

2 mins read

This article explains how to resize comments in WinForms XlsIO using C#/VB.NET.

How to resize comments in XlsIO?

Comments are used as notes for a cell in worksheet. The comment shape size can be resized by changing the height and width. XlsIO provides support for changing the width and height of the comments.

To resize the comment, please set height and width of the comment like following code snippet.

//Add comment in cell 'A1'
ICommentShape comment = worksheet["A1"].AddComment();
 
comment.Text = "Resized comment";
 
// Height and Width measured in points
comment.Height = 100;
comment.Width = 100;
comment.IsVisible = true;
 

 

To know more about comments in XlsIO, please refer the documentation.

Download complete sample

The following C#/VB.NET complete code snippet shows how to resize comments in XlsIO.

using Syncfusion.XlsIO;
using Syncfusion.XlsIO.Implementation.Shapes;
using System.Drawing;
using System.IO;
using System.Reflection;
 
namespace XlsIO_Sample
{
    class Program
    {
        public static void Main(string[] args)
        {
            //Instantiate the spreadsheet creation engine
            using (ExcelEngine excelEngine = new ExcelEngine())
            {
                IApplication application = excelEngine.Excel;
 
                //Create workbook
                IWorkbook workbook = application.Workbooks.Create(1);
                IWorksheet worksheet = workbook.Worksheets[0];
 
                //Add comment in cell 'A1'
                ICommentShape comment = worksheet["A1"].AddComment();
 
                comment.Text = "Resized comment";
 
                // Height and Width measured in points
                comment.Height = 100;
                comment.Width = 100;
                comment.IsVisible = true;
 
                //Save and close the workbook
                Stream stream = File.Create("Output.xlsx");
                workbook.SaveAs(stream);
            }
        }
    }
}
 

 

Imports Syncfusion.XlsIO
Imports Syncfusion.XlsIO.Implementation
Imports System.Drawing
Imports System.IO
Imports System.Reflection
 
Namespace XlsIO_Sample
 
    Class Program
 
        Public Shared Sub Main(ByVal args As String())
            'Instantiate spreadsheet creation engine
            Using excelEngine As ExcelEngine = New ExcelEngine()
 
                Dim application As IApplication = excelEngine.Excel
 
                'Create a workbook
                Dim workbook As IWorkbook = application.Workbooks.Create(1)
                Dim worksheet As IWorksheet = workbook.Worksheets(0)
 
                'Add comment in cell 'A1'
                Dim comment As ICommentShape = worksheet("A1").AddComment()
 
                comment.Text = "Resized comment"
 
                ' Height And Width measured in points
                comment.Height = 100
                comment.Width = 100
                comment.IsVisible = True
 
                'Save and close the workbook
                Dim stream As Stream = File.Create("Output.xlsx")
                workbook.SaveAs(stream)
            End Using
        End Sub
    End Class
End Namespace
 

 

The following screenshot shows how to resize comment in XlsIO.

Resizing comment in Excel Library

Did you find this information helpful?
Yes
No
Help us improve this page
Please provide feedback or comments
Comments (0)
Please sign in to leave a comment
Access denied
Access denied