[]
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);
floatfloatfloatfloatITextRange object that represents the text in the object.voidsetDirection(TextDirection value) voidvoidsetMarginBottom(float bottom) voidsetMarginLeft(float left) voidsetMarginRight(float right) voidsetMarginTop(float top) voidsetVerticalAnchor(VerticalAnchor value) 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();
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);
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.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();
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);
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.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();
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);
right - The right margin of the text frame, in points.
IShape shape = worksheet.getShapes().addShape(AutoShapeType.Rectangle, 10, 10, 120, 60);
ITextFrame textFrame = shape.getTextFrame();
textFrame.setMarginTop(8.0f);
float marginTop = textFrame.getMarginTop();
IShape shape = worksheet.getShapes().addShape(AutoShapeType.Rectangle, 10, 10, 120, 60);
ITextFrame textFrame = shape.getTextFrame();
textFrame.setMarginTop(8.0f);
top - The top margin of the text frame, in points.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();
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);
value - The text direction to apply to the text frame.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");
ITextRange object that represents the text in the object.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();
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);
value - The horizontal anchor for the text frame.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();
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);
value - The vertical anchor for the Text frame in the shape.