extends java.lang.Object implements RichTextString
Rich text unicode string. These strings can have fonts applied to arbitary parts of the string. Most strings in a workbook have formatting applied at the cell level, that is, the entire string in the cell has the same formatting applied. In these cases, the formatting for the cell is stored in the styles part, and the string for the cell can be shared across the workbook. The following code illustrates the example. cell1.setCellValue(new XSSFRichTextString("Apache POI")); cell2.setCellValue(new XSSFRichTextString("Apache POI")); cell3.setCellValue(new XSSFRichTextString("Apache POI")); In the above example all three cells will use the same string cached on workbook level. Some strings in the workbook may have formatting applied at a level that is more granular than the cell level. For instance, specific characters within the string may be bolded, have coloring, italicizing, etc. In these cases, the formatting is stored along with the text in the string table, and is treated as a unique entry in the workbook. The following xml and code snippet illustrate this. XSSFRichTextString s1 = new XSSFRichTextString("Apache POI"); s1.applyFont(boldArial); cell1.setCellValue(s1); XSSFRichTextString s2 = new XSSFRichTextString("Apache POI"); s2.applyFont(italicCourier); cell2.setCellValue(s2); protected static void preserveSpaces (org.openxmlformats.schemas.spreadsheetml.x2006.main.STXstring xs)
Add the xml:spaces="preserve" attribute if the string has leading or trailing spaces
setString (java.lang.String s)
Removes any formatting and sets new string value
protected void setStylesTableReference ( StylesTable tbl) protected static org.openxmlformats.schemas.spreadsheetml.x2006.main.CTFont toCTFont (org.openxmlformats.schemas.spreadsheetml.x2006.main.CTRPrElt pr)
CTRPrElt --> CTFont adapter
java.lang.String toString ()
Returns the plain string representation.

XSSFRichTextString

@Internal
public XSSFRichTextString(org.openxmlformats.schemas.spreadsheetml.x2006.main.CTRst st)
Create a rich text string from the supplied XML bean
applyFont in interface RichTextString
Parameters:
startIndex - The start index to apply the font to (inclusive)
endIndex - The end index to apply the font to (exclusive)
fontIndex - The font to use.
applyFont in interface RichTextString
Parameters:
startIndex - The start index to apply the font to (inclusive)
endIndex - The end index to apply to font to (exclusive)
font - The index of the font to use.

applyFont

public void applyFont(short fontIndex)
Applies the specified font to the entire string.
Specified by:
applyFont in interface RichTextString
Parameters:
fontIndex - the font to apply.
public void append(java.lang.String text,
                   XSSFFont font)
Append new text to this text run and apply the specify font to it
Parameters:
text - the text to append
font - the font to apply to the appended text or null if no formatting is required

hasFormatting

public boolean hasFormatting()
Does this string have any explicit formatting applied, or is it just text in the default style?

clearFormatting

public void clearFormatting()
Removes any formatting that may have been applied to the string.
Specified by:
clearFormatting in interface RichTextString

getIndexOfFormattingRun

public int getIndexOfFormattingRun(int index)
The index within the string to which the specified formatting run applies.
Specified by:
getIndexOfFormattingRun in interface RichTextString
Parameters:
index - the index of the formatting run
Returns:
the index within the string.

getLengthOfFormattingRun

public int getLengthOfFormattingRun(int index)
Returns the number of characters this format run covers.
Parameters:
index - the index of the formatting run
Returns:
the number of characters this format run covers
getString in interface RichTextString
Returns:
The string representation of this RichText string, null if there is no data at all

setString

public void setString(java.lang.String s)
Removes any formatting and sets new string value
Parameters:
s - new string value

getFontOfFormattingRun

public XSSFFont getFontOfFormattingRun(int index)
Gets a copy of the font used in a particular formatting run.
Parameters:
index - the index of the formatting run
Returns:
A copy of the font used or null if no formatting is applied to the specified text run.

getFontAtIndex

public XSSFFont getFontAtIndex(int index)
Return a copy of the font in use at a particular index.
Parameters:
index - The index.
Returns:
A copy of the font that's currently being applied at that index or null if no font is being applied or the index is out of range.

getCTRst

@Internal
public org.openxmlformats.schemas.spreadsheetml.x2006.main.CTRst getCTRst()
Return the underlying xml bean

toCTFont

protected static org.openxmlformats.schemas.spreadsheetml.x2006.main.CTFont toCTFont(org.openxmlformats.schemas.spreadsheetml.x2006.main.CTRPrElt pr)
CTRPrElt --> CTFont adapter

preserveSpaces

protected static void preserveSpaces(org.openxmlformats.schemas.spreadsheetml.x2006.main.STXstring xs)
Add the xml:spaces="preserve" attribute if the string has leading or trailing spaces
Parameters:
xs - the string to check