Class ExcelRichText

java.lang.Object
io.github.dornol.excelkit.excel.ExcelRichText

public class ExcelRichText extends Object
Fluent builder for creating rich text content with mixed formatting within a single Excel cell.

Supports partial bold, italic, underline, strikethrough, font color, and font size applied to individual text segments.

Example usage:


 ExcelRichText rt = new ExcelRichText()
     .text("Hello ")
     .bold("World")
     .text(" — ")
     .styled("red text", s -> s.color(ExcelColor.RED).italic(true));
 
See Also:
  • Constructor Details

    • ExcelRichText

      public ExcelRichText()
      Creates a new empty rich text instance.
  • Method Details

    • text

      public ExcelRichText text(String text)
      Appends plain (unstyled) text.
      Parameters:
      text - the text to append
      Returns:
      this builder
    • bold

      public ExcelRichText bold(String text)
      Appends bold text.
      Parameters:
      text - the text to append in bold
      Returns:
      this builder
    • italic

      public ExcelRichText italic(String text)
      Appends italic text.
      Parameters:
      text - the text to append in italic
      Returns:
      this builder
    • styled

      public ExcelRichText styled(String text, Consumer<ExcelRichText.FontStyle> configurer)
      Appends text with fully customized font styling.
      Parameters:
      text - the text to append
      configurer - a consumer that configures the ExcelRichText.FontStyle
      Returns:
      this builder
    • toString

      public String toString()
      Returns the plain text content (without formatting) for display or width calculation.
      Overrides:
      toString in class Object