File Formats

  • Code Examples
  • Upgrade Guide
  • User Guide
  • Demos
  • Support
  • Forums
  • Download
Interface ITextBox

    Show / Hide Table of Contents

    Interface ITextBox

    This interface represents TextBox form control.

    Inherited Members
    IParentApplication.Application
    IParentApplication.Parent
    Namespace: Syncfusion.XlsIO
    Assembly: Syncfusion.XlsIO.Base.dll
    Syntax
    public interface ITextBox : IParentApplication

    Properties

    HAlignment

    Horizontal alignment of the text.

    Declaration
    ExcelCommentHAlign HAlignment { get; set; }
    Property Value
    Type Description
    ExcelCommentHAlign
    Examples

    By default Left is set to HAlignment. Here for example, we set Center to HAlignment 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 textbox
                ITextBox textbox = worksheet.TextBoxes.AddTextBox(5, 5, 40, 100);
    
                //Set text
                textbox.Text = "Text";
    
                //Set alignment
                textbox.HAlignment = ExcelCommentHAlign.Left;
    
                //Save and dispose
                workbook.SaveAs("Shapes.xlsx");
                workbook.Close();
            }

    IsTextLocked

    Indicates whether comment text is locked.

    Declaration
    bool IsTextLocked { get; set; }
    Property Value
    Type Description
    System.Boolean
    Examples
            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 textbox
                ITextBox textbox = worksheet.TextBoxes.AddTextBox(5, 5, 40, 100);
    
                //Set text
                textbox.Text = "Text";
    
                //Set locked
                textbox.IsTextLocked = false;
    
                //Set sheet protection
                worksheet.Protect("", ExcelSheetProtection.All);
    
                //Save and dispose
                workbook.SaveAs("Shapes.xlsx");
                workbook.Close();
            }

    RichText

    Text of the comment. Read-only.

    Declaration
    IRichTextString RichText { get; set; }
    Property Value
    Type Description
    IRichTextString
    Examples
            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 textbox
                ITextBox textbox = worksheet.TextBoxes.AddTextBox(5, 5, 20, 100);
    
                //Set rich text
                IRichTextString richText = textbox.RichText;
    
                //Set font
                IFont font = workbook.CreateFont();
                font.Color = ExcelKnownColors.Red;
    
                //Set text
                richText.Text = "Text";
    
                //Apply format
                richText.SetFont(0, 3, font);
    
                //Save and dispose
                workbook.SaveAs("Shapes.xlsx");
                workbook.Close();
            }

    Text

    Text of the comment.

    Declaration
    string Text { get; set; }
    Property Value
    Type Description
    System.String
    Examples
            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 textbox
                ITextBox textbox = worksheet.TextBoxes.AddTextBox(5, 5, 40, 100);
    
                //Set text
                textbox.Text = "Text";
    
                //Set alignment
                textbox.HAlignment = ExcelCommentHAlign.Center;
                textbox.VAlignment = ExcelCommentVAlign.Center;
    
                //Save and dispose
                workbook.SaveAs("Shapes.xlsx");
                workbook.Close();
            }

    TextRotation

    Text rotation.

    Declaration
    ExcelTextRotation TextRotation { get; set; }
    Property Value
    Type Description
    ExcelTextRotation
    Examples
            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 textbox
                ITextBox textbox = worksheet.TextBoxes.AddTextBox(5, 5, 200, 100);
    
                //Set text
                textbox.Text = "Text";
    
                //Set rotation
                textbox.TextRotation = ExcelTextRotation.Clockwise;
    
                //Save and dispose
                workbook.SaveAs("Shapes.xlsx");
                workbook.Close();
            }

    VAlignment

    Vertical alignment of the text.

    Declaration
    ExcelCommentVAlign VAlignment { get; set; }
    Property Value
    Type Description
    ExcelCommentVAlign
    Examples

    By default Top is set to VAlignment. Here for example, we set Center to HAlignment 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 textbox
                ITextBox textbox = worksheet.TextBoxes.AddTextBox(5, 5, 200, 100);
    
                //Set text
                textbox.Text = "Text";
    
                //Set alignment
                textbox.VAlignment = ExcelCommentVAlign.Center;
    
                //Save and dispose
                workbook.SaveAs("Shapes.xlsx");
                workbook.Close();
            }
    Back to top Generated by DocFX
    Copyright © 2001 - 2023 Syncfusion Inc. All Rights Reserved