[]
        
(Showing Draft Content)

ITextFrame

Interface ITextFrame


public interface ITextFrame
Represents the text frame in an IShape object.

An ITextFrame provides access to the text content and layout settings of a shape, including the text range, text direction, text anchoring, and inner margins.


 IShape shape = worksheet.getShapes().addShape(AutoShapeType.Rectangle, 10, 10, 120, 60);
 ITextFrame textFrame = shape.getTextFrame();
 textFrame.getTextRange().setText("Hello");
 textFrame.setDirection(TextDirection.Vertical);
 
  • Method Summary

    Modifier and Type
    Method
    Description
    Gets the text direction.
    Gets the horizontal anchor for the text frame in the shape.
    float
    Gets the distance (in points) between the bottom of the text frame and the bottom of the inscribed rectangle of the shape that contains the text.
    float
    Gets the distance (in points) between the left of the text frame and the left of the inscribed rectangle of the shape that contains the text.
    float
    Gets the distance, in points, between the right edge of the text frame and the right edge of the inscribed rectangle of the shape that contains the text.
    float
    Gets the distance (in points) between the top of the text frame and the top of the inscribed rectangle of the shape that contains the text.
    Returns the ITextRange object that represents the text in the object.
    Gets the vertical anchor for the text frame in the shape.
    void
    Sets the text direction.
    void
    Sets the horizontal anchor for the text frame in the shape.
    void
    setMarginBottom(float bottom)
    Sets the distance (in points) between the bottom of the text frame and the bottom of the inscribed rectangle of the shape that contains the text.
    void
    setMarginLeft(float left)
    Sets the distance (in points) between the left of the text frame and the left of the inscribed rectangle of the shape that contains the text.
    void
    setMarginRight(float right)
    Sets the distance, in points, between the right edge of the text frame and the right edge of the inscribed rectangle of the shape that contains the text.
    void
    setMarginTop(float top)
    Sets the distance (in points) between the top of the text frame and the top of the inscribed rectangle of the shape that contains the text.
    void
    Sets the vertical anchor for the Text frame in the shape.
  • Method Details

    • getMarginBottom

      float getMarginBottom()
      Gets the distance (in points) between the bottom of the text frame and the bottom of the inscribed rectangle of the shape that contains the text.

      Use this property to determine the inner bottom margin applied to text within a shape's text frame.

      
       IShape shape = worksheet.getShapes().addShape(AutoShapeType.Rectangle, 10, 10, 120, 60);
       ITextFrame textFrame = shape.getTextFrame();
       textFrame.setMarginBottom(8.0f);
       float marginBottom = textFrame.getMarginBottom();
       
      Returns:
      The distance, in points, between the bottom of the text frame and the bottom of the inscribed rectangle of the shape that contains the text.
    • setMarginBottom

      void setMarginBottom(float bottom)
      Sets the distance (in points) between the bottom of the text frame and the bottom of the inscribed rectangle of the shape that contains the text.

      Use this property to set the inner bottom margin applied to text within a shape's text frame.

      
       IShape shape = worksheet.getShapes().addShape(AutoShapeType.Rectangle, 10, 10, 120, 60);
       ITextFrame textFrame = shape.getTextFrame();
       textFrame.setMarginBottom(8.0f);
       
      Parameters:
      bottom - The distance, in points, between the bottom of the text frame and the bottom of the inscribed rectangle of the shape that contains the text.
    • getMarginLeft

      float getMarginLeft()
      Gets the distance (in points) between the left of the text frame and the left of the inscribed rectangle of the shape that contains the text.

      Use this property to determine the inner left margin applied to text within a shape's text frame.

      
       IShape shape = worksheet.getShapes().addShape(AutoShapeType.Rectangle, 10, 10, 120, 60);
       ITextFrame textFrame = shape.getTextFrame();
       textFrame.setMarginLeft(6.0f);
       float marginLeft = textFrame.getMarginLeft();
       
      Returns:
      The distance, in points, between the left of the text frame and the left of the inscribed rectangle of the shape that contains the text.
    • setMarginLeft

      void setMarginLeft(float left)
      Sets the distance (in points) between the left of the text frame and the left of the inscribed rectangle of the shape that contains the text.

      Use this property to set the inner left margin applied to text within a shape's text frame.

      
       IShape shape = worksheet.getShapes().addShape(AutoShapeType.Rectangle, 10, 10, 120, 60);
       ITextFrame textFrame = shape.getTextFrame();
       textFrame.setMarginLeft(6.0f);
       
      Parameters:
      left - The distance, in points, between the left of the text frame and the left of the inscribed rectangle of the shape that contains the text.
    • getMarginRight

      float getMarginRight()
      Gets the distance, in points, between the right edge of the text frame and the right edge of the inscribed rectangle of the shape that contains the text.

      This value controls the internal right margin for text displayed in a shape.

      
       IShape shape = worksheet.getShapes().addShape(AutoShapeType.Rectangle, 10, 10, 120, 60);
       ITextFrame textFrame = shape.getTextFrame();
       textFrame.setMarginRight(6.0f);
       float marginRight = textFrame.getMarginRight();
       
      Returns:
      The right margin of the text frame, in points.
    • setMarginRight

      void setMarginRight(float right)
      Sets the distance, in points, between the right edge of the text frame and the right edge of the inscribed rectangle of the shape that contains the text.

      This value controls the internal right margin for text displayed in a shape.

      
       IShape shape = worksheet.getShapes().addShape(AutoShapeType.Rectangle, 10, 10, 120, 60);
       ITextFrame textFrame = shape.getTextFrame();
       textFrame.setMarginRight(6.0f);
       
      Parameters:
      right - The right margin of the text frame, in points.
    • getMarginTop

      float getMarginTop()
      Gets the distance (in points) between the top of the text frame and the top of the inscribed rectangle of the shape that contains the text.
      
       IShape shape = worksheet.getShapes().addShape(AutoShapeType.Rectangle, 10, 10, 120, 60);
       ITextFrame textFrame = shape.getTextFrame();
       textFrame.setMarginTop(8.0f);
       float marginTop = textFrame.getMarginTop();
       
      Returns:
      The top margin of the text frame, in points.
    • setMarginTop

      void setMarginTop(float top)
      Sets the distance (in points) between the top of the text frame and the top of the inscribed rectangle of the shape that contains the text.
      
       IShape shape = worksheet.getShapes().addShape(AutoShapeType.Rectangle, 10, 10, 120, 60);
       ITextFrame textFrame = shape.getTextFrame();
       textFrame.setMarginTop(8.0f);
       
      Parameters:
      top - The top margin of the text frame, in points.
    • getDirection

      TextDirection getDirection()
      Gets the text direction.

      Use this property to determine how text is oriented within the shape's text frame, such as horizontal, vertical, rotated, or stacked text.

      
       IShape shape = worksheet.getShapes().addShape(AutoShapeType.Rectangle, 10, 10, 120, 60);
       ITextFrame textFrame = shape.getTextFrame();
       textFrame.setDirection(TextDirection.Vertical);
       TextDirection direction = textFrame.getDirection();
       
      Returns:
      The text direction of the text frame.
    • setDirection

      void setDirection(TextDirection value)
      Sets the text direction.

      Use this property to control how text is oriented within the shape's text frame, such as horizontal, vertical, rotated, or stacked text.

      
       IShape shape = worksheet.getShapes().addShape(AutoShapeType.Rectangle, 10, 10, 120, 60);
       ITextFrame textFrame = shape.getTextFrame();
       textFrame.getTextRange().setText("Hello");
       textFrame.setDirection(TextDirection.Vertical);
       
      Parameters:
      value - The text direction to apply to the text frame.
    • getTextRange

      ITextRange getTextRange()
      Returns the ITextRange object that represents the text in the object.

      Use the returned text range to read or modify the shape text and its formatting.

      
       IShape shape = worksheet.getShapes().addShape(AutoShapeType.Rectangle, 10, 10, 120, 60);
       ITextFrame textFrame = shape.getTextFrame();
       ITextRange textRange = textFrame.getTextRange();
       textRange.setText("Hello");
       
      Returns:
      The ITextRange object that represents the text in the object.
    • getHorizontalAnchor

      HorizontalAnchor getHorizontalAnchor()
      Gets the horizontal anchor for the text frame in the shape.

      Use this property to determine how the text frame is anchored horizontally within the shape. To control the horizontal alignment of the text itself, use ITextRange.setTextAlignment(TextAlignmentAnchor).

      
       IShape shape = worksheet.getShapes().addShape(AutoShapeType.Rectangle, 20, 20, 120, 80);
       shape.getTextFrame().setHorizontalAnchor(HorizontalAnchor.Center);
       HorizontalAnchor anchor = shape.getTextFrame().getHorizontalAnchor();
       
      Returns:
      The horizontal anchor for the text frame in the shape.
    • setHorizontalAnchor

      void setHorizontalAnchor(HorizontalAnchor value)
      Sets the horizontal anchor for the text frame in the shape.

      This method controls the horizontal position of the text frame within the shape. If you want to set the horizontal alignment of the text, use ITextRange.setTextAlignment(TextAlignmentAnchor).

      
       IShape shape = worksheet.getShapes().addShape(AutoShapeType.Rectangle, 10, 10, 120, 60);
       ITextFrame textFrame = shape.getTextFrame();
       textFrame.getTextRange().setText("Centered text");
       textFrame.setHorizontalAnchor(HorizontalAnchor.Center);
       
      Parameters:
      value - The horizontal anchor for the text frame.
    • getVerticalAnchor

      VerticalAnchor getVerticalAnchor()
      Gets the vertical anchor for the text frame in the shape.

      The vertical anchor controls whether the text in the shape is aligned to the top, middle, or bottom of the text frame.

      
       IShape shape = worksheet.getShapes().addShape(AutoShapeType.Rectangle, 10, 10, 120, 60);
       ITextFrame textFrame = shape.getTextFrame();
       textFrame.setVerticalAnchor(VerticalAnchor.AnchorMiddle);
       VerticalAnchor verticalAnchor = textFrame.getVerticalAnchor();
       
      Returns:
      The vertical anchor of the text frame in the shape.
    • setVerticalAnchor

      void setVerticalAnchor(VerticalAnchor value)
      Sets the vertical anchor for the Text frame in the shape.

      Use this method to position the text frame at the top, middle, or bottom of the shape. The anchor position is specified by a VerticalAnchor value.

      
       IShape shape = worksheet.getShapes().addShape(AutoShapeType.Rectangle, 10, 10, 120, 60);
       ITextFrame textFrame = shape.getTextFrame();
       textFrame.getTextRange().setText("Quarterly Sales");
       textFrame.setVerticalAnchor(VerticalAnchor.AnchorMiddle);
       
      Parameters:
      value - The vertical anchor for the Text frame in the shape.