menu

UWP

  • Code Examples
  • Upgrade Guide
  • User Guide
  • Demos
  • Support
  • Forums
  • Download
Interface ITextRange - UWP API Reference | Syncfusion

    Show / Hide Table of Contents

    Interface ITextRange

    Returns the TextRange object that represents the text in the object. Read-only.

    Namespace: Syncfusion.XlsIO
    Assembly: Syncfusion.XlsIO.UWP.dll
    Syntax
    public interface ITextRange

    Properties

    RichText

    Text of the comment. Read-only.

    Declaration
    IRichTextString RichText { get; }
    Property Value
    Type
    IRichTextString
    Examples

    The following code illustrates how to set RichText inside the IShape.

            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 shape
                IShape shape = worksheet.Shapes.AddAutoShapes(AutoShapeType.Rectangle, 2, 2, 40, 100);
    
                //Set text frame
                ITextFrame textFrame = shape.TextFrame;
    
                //Set text range
                ITextRange textRange = textFrame.TextRange;
    
                //Set rich text
                IRichTextString richText = textRange.RichText;
                richText.Text = "Sample";
    
                //Create font
                IFont font = workbook.CreateFont();
                font.Color = ExcelKnownColors.Red;
    
                //Apply rich text format
                richText.SetFont(0, 5, font);
    
                //Save and dispose
                workbook.SaveAs("Shapes.xlsx");
                workbook.Close();
            }

    Text

    Gets or sets the text property of the text range.

    Declaration
    string Text { get; set; }
    Property Value
    Type
    System.String
    Examples

    The following code illustrates how to set Text inside the IShape.

            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 shape
                IShape shape = worksheet.Shapes.AddAutoShapes(AutoShapeType.Rectangle, 2, 2, 40, 100);
    
                //Set text frame
                ITextFrame textFrame = shape.TextFrame;
    
                //Set text range
                ITextRange textRange = textFrame.TextRange;
    
                //Set text
                textRange.Text = "Sample text";
    
                //Save and dispose
                workbook.SaveAs("Shapes.xlsx");
                workbook.Close();
            }

    Extension Methods

    DateTimeExtension.ToDateTime(Object)
    Back to top Generated by DocFX
    Copyright © 2001 - 2025 Syncfusion Inc. All Rights Reserved