[]
        
(Showing Draft Content)

IRichText

Interface IRichText

All Superinterfaces:
Iterable<ITextRun>

public interface IRichText extends Iterable<ITextRun>
Represents rich text content in a cell.

An IRichText object contains a collection of ITextRun objects that together define the text and character-level formatting for a cell. You can obtain this interface from IRange.getRichText() and use it to append formatted text runs or iterate through existing text runs.


 IRichText richText = worksheet.getRange("A1").getRichText();
 ITextRun run1 = richText.add("Document ");
 run1.getFont().setBold(true);
 ITextRun run2 = richText.add("Solutions");
 run2.getFont().setColor(Color.GetBlue());
 
  • Method Details

    • add

      ITextRun add(String text)
      Adds a text run into the current rich text object.

      The new text run is appended to this IRichText and can be used to apply character-level formatting to the added text.

      
       IRichText richText = worksheet.getRange("A1").getRichText();
       ITextRun textRun = richText.add("Document Solutions");
       textRun.getFont().setBold(true);
       
      Parameters:
      text - The text to add to the current rich text object.
      Returns:
      The newly added ITextRun.
    • getCount

      int getCount()
      Gets the count of ITextRun objects.
      
       IRichText richText = worksheet.getRange("A1").getRichText();
       richText.add("Document ");
       richText.add("Solutions");
       int count = richText.getCount();
       
      Returns:
      The number of ITextRun objects in this rich text object.
    • getPlainText

      String getPlainText()
      Gets the plain text that is composed of all ITextRun objects.

      Returns the concatenated text content of the rich text without exposing individual text run formatting.

      
       IRichText richText = worksheet.getRange("A1").getRichText();
       richText.add("Document ");
       richText.add("Solutions");
       String plainText = richText.getPlainText();
       
      Returns:
      The plain text composed of all ITextRun objects.