[]
        
(Showing Draft Content)

ITextRange

Interface ITextRange


public interface ITextRange
Represents the text frame in the com.grapecity.documents.excel.IShape.

 IShape shape = worksheet.getShapes().addShape(AutoShapeType.Rectangle, 10, 10, 200, 80);
 ITextRange textRange = shape.getTextFrame().getTextRange();
 textRange.setText("Sales Report");
 textRange.setTextAlignment(TextAlignmentAnchor.Center);
 
  • Method Details

    • getText

      String getText()
      Gets a String value that represents the text in a text range.
      
       ITextRange textRange = shape.getTextFrame().getTextRange();
       textRange.setText("Sales Report");
       String text = textRange.getText();
       
      Returns:
      A String value that represents the text in a text range.
    • setText

      void setText(String value)
      Sets a String value that represents the text in a text range.
      
       ITextRange textRange = shape.getTextFrame().getTextRange();
       textRange.setText("Sales Report");
       String text = textRange.getText();
       
      Parameters:
      value - The text to set.
    • getFont

      IFontFormat getFont()
      Gets the IFontFormat object that represents character formatting for the text range.
      
       ITextRange textRange = shape.getTextFrame().getTextRange();
       textRange.setText("Sales Report");
       textRange.getFont().setBold(true);
       boolean bold = textRange.getFont().getBold();
       
      Returns:
      The IFontFormat object that represents character formatting for the text range.
    • getParagraphs

      ITextRange getParagraphs()
      Gets the paragraphs of ITextRange.

      This method is only used when the type is TextRangeType.Body; otherwise, it throws InvalidOperationException.

      
       ITextRange body = shape.getTextFrame().getTextRange();
       body.getParagraphs().add("Sales Report");
       ITextRange paragraphs = body.getParagraphs();
       int count = paragraphs.getCount();
       
      Returns:
      The paragraphs of.
    • getRuns

      ITextRange getRuns()
      Gets the runs of ITextRange.

      This method is only used when the type is TextRangeType.Paragraph; otherwise, it throws InvalidOperationException.

      
       ITextRange body = shape.getTextFrame().getTextRange();
       ITextRange paragraph = body.getParagraphs().add("Sales Report");
       ITextRange runs = paragraph.getRuns();
       int count = runs.getCount();
       
      Returns:
      The runs of.
    • get

      ITextRange get(int index)
      Gets the ITextRange with the specified index.
      
       ITextRange body = shape.getTextFrame().getTextRange();
       body.getParagraphs().add("Sales Report");
       ITextRange firstParagraph = body.getParagraphs().get(0);
       
      Parameters:
      index - The index. ITextRange
      Returns:
      The with the specified index.
    • getCount

      int getCount()
      Returns the number of objects in the collection.
      
       ITextRange body = shape.getTextFrame().getTextRange();
       body.getParagraphs().add("Sales Report");
       int count = body.getParagraphs().getCount();
       
      Returns:
      The number of objects in the collection.
    • getIndex

      int getIndex()
      Returns the index in the collection.
      
       ITextRange body = shape.getTextFrame().getTextRange();
       body.getParagraphs().add("Sales Report");
       ITextRange firstParagraph = body.getParagraphs().get(0);
       int index = firstParagraph.getIndex();
       
      Returns:
      The index in the collection.
    • getTextAlignment

      TextAlignmentAnchor getTextAlignment()
      Gets the horizontal alignment of the text.
      
       ITextRange textRange = shape.getTextFrame().getTextRange();
       textRange.setText("Sales Report");
       textRange.setTextAlignment(TextAlignmentAnchor.Center);
       TextAlignmentAnchor alignment = textRange.getTextAlignment();
       
      Returns:
      The horizontal alignment of the text.
    • setTextAlignment

      void setTextAlignment(TextAlignmentAnchor textAlignment)
      Sets the horizontal alignment of the text.
      
       ITextRange textRange = shape.getTextFrame().getTextRange();
       textRange.setText("Sales Report");
       textRange.setTextAlignment(TextAlignmentAnchor.Center);
       TextAlignmentAnchor alignment = textRange.getTextAlignment();
       
      Parameters:
      textAlignment - The horizontal alignment for the text.
    • getType

      TextRangeType getType()
      Returns the type of ITextRange.
      
       ITextRange textRange = shape.getTextFrame().getTextRange();
       TextRangeType type = textRange.getType();
       
      Returns:
      The type of.
    • add

      ITextRange add(String newText)
      Adds text to the specified collection.
      
       ITextRange body = shape.getTextFrame().getTextRange();
       ITextRange paragraph = body.getParagraphs().add("Sales Report");
       String text = paragraph.getText();
       
      Parameters:
      newText - The new text.
      Returns:
      The new ITextRange. This method is only used on body and paragraph text ranges. Calling it on a body text range adds a paragraph with a run. Calling it on a paragraph text range adds a run.
    • add

      ITextRange add()
      Adds text to the specified collection.
      
       ITextRange body = shape.getTextFrame().getTextRange();
       ITextRange paragraph = body.getParagraphs().add();
       paragraph.setText("Sales Report");
       
      Returns:
      The newly added ITextRange object; see ITextRange.
    • add

      ITextRange add(String newText, int position)
      Adds text to the specified collection.
      
       ITextRange body = shape.getTextFrame().getTextRange();
       body.getParagraphs().add("First paragraph");
       ITextRange insertedParagraph = body.getParagraphs().add("Title", 0);
       
      Parameters:
      newText - The new text.
      position - The position that you want to insert.
      Returns:
      The new ITextRange. This method is only used on body and paragraph text ranges. Calling it on a body text range adds a paragraph with a run. Calling it on a paragraph text range adds a run.
    • delete

      void delete()
      Deletes from parent.
      
       ITextRange body = shape.getTextFrame().getTextRange();
       ITextRange paragraph = body.getParagraphs().add("Draft note");
       paragraph.delete();