How to resize comment box using C#,VB.NET?
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 a 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 the height and width of the comment like the 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.
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.
Take a moment to peruse the documentation where you can find basic Excel document processing options along with the features like import and export data, chart, formulas, conditional formatting, data validation, tables, pivot tables and, protect the Excel documents, and most importantly, the PDF, CSV and Image conversions with code examples.
Conclusion
I hope you enjoyed learning about How to resize comment box using C#,VB.NET.
You can refer to our XIsIO’s feature tour page to learn about its other groundbreaking features. Explore our UG documentation and online demos to understand how to manipulate data in Excel documents.
If you are an existing user, you can access our latest components from the License and Downloads page. For new users, you can try our 30-day free trial to check out XlsIO and other Syncfusion® components.
If you have any queries or require clarification, please let us know in the comments below or contact us through our support forums, Support Tickets, or feedback portal. We are always happy to assist you!