Package org.apache.poi.xssf.usermodel
Class XSSFTextRun
- java.lang.Object
-
- org.apache.poi.xssf.usermodel.XSSFTextRun
-
public class XSSFTextRun extends java.lang.Object
Represents a run of text within the containing text body. The run element is the lowest level text separation mechanism within a text body.
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description double
getCharacterSpacing()
java.awt.Color
getFontColor()
java.lang.String
getFontFamily()
double
getFontSize()
byte
getPitchAndFamily()
java.lang.String
getText()
TextCap
getTextCap()
CTRegularTextRun
getXmlObject()
boolean
isBold()
boolean
isItalic()
boolean
isStrikethrough()
boolean
isSubscript()
boolean
isSuperscript()
boolean
isUnderline()
void
setBaselineOffset(double baselineOffset)
Set the baseline for both the superscript and subscript fonts.void
setBold(boolean bold)
Specifies whether this run of text will be formatted as bold textvoid
setCharacterSpacing(double spc)
Set the spacing between characters within a text run.void
setFont(java.lang.String typeface)
Specifies the typeface, or name of the font that is to be used for this text run.void
setFontColor(java.awt.Color color)
void
setFontFamily(java.lang.String typeface, byte charset, byte pictAndFamily, boolean isSymbol)
void
setFontSize(double fontSize)
void
setItalic(boolean italic)
void
setStrikethrough(boolean strike)
Specifies whether a run of text will be formatted as strikethrough text.void
setSubscript(boolean flag)
Set whether the text in this run is formatted as subscript.void
setSuperscript(boolean flag)
Set whether the text in this run is formatted as superscript.void
setText(java.lang.String text)
void
setUnderline(boolean underline)
java.lang.String
toString()
-
-
-
Method Detail
-
getText
public java.lang.String getText()
-
setText
public void setText(java.lang.String text)
-
getXmlObject
public CTRegularTextRun getXmlObject()
-
setFontColor
public void setFontColor(java.awt.Color color)
-
getFontColor
public java.awt.Color getFontColor()
-
setFontSize
public void setFontSize(double fontSize)
- Parameters:
fontSize
- font size in points. The value of-1
unsets the Sz attribute from the underlying xml bean
-
getFontSize
public double getFontSize()
- Returns:
- font size in points or -1 if font size is not set.
-
getCharacterSpacing
public double getCharacterSpacing()
- Returns:
- the spacing between characters within a text run, If this attribute is omitted then a value of 0 or no adjustment is assumed.
-
setCharacterSpacing
public void setCharacterSpacing(double spc)
Set the spacing between characters within a text run.The spacing is specified in points. Positive values will cause the text to expand, negative values to condense.
- Parameters:
spc
- character spacing in points.
-
setFont
public void setFont(java.lang.String typeface)
Specifies the typeface, or name of the font that is to be used for this text run.- Parameters:
typeface
- the font to apply to this text run. The value ofnull
unsets the Typeface attribute from the underlying xml.
-
setFontFamily
public void setFontFamily(java.lang.String typeface, byte charset, byte pictAndFamily, boolean isSymbol)
-
getFontFamily
public java.lang.String getFontFamily()
- Returns:
- font family or null if not set
-
getPitchAndFamily
public byte getPitchAndFamily()
-
setStrikethrough
public void setStrikethrough(boolean strike)
Specifies whether a run of text will be formatted as strikethrough text.- Parameters:
strike
- whether a run of text will be formatted as strikethrough text.
-
isStrikethrough
public boolean isStrikethrough()
- Returns:
- whether a run of text will be formatted as strikethrough text. Default is false.
-
isSuperscript
public boolean isSuperscript()
- Returns:
- whether a run of text will be formatted as a superscript text. Default is false.
-
setBaselineOffset
public void setBaselineOffset(double baselineOffset)
Set the baseline for both the superscript and subscript fonts.The size is specified using a percentage. Positive values indicate superscript, negative values indicate subscript.
-
setSuperscript
public void setSuperscript(boolean flag)
Set whether the text in this run is formatted as superscript. Default base line offset is 30%- See Also:
setBaselineOffset(double)
-
setSubscript
public void setSubscript(boolean flag)
Set whether the text in this run is formatted as subscript. Default base line offset is -25%.- See Also:
setBaselineOffset(double)
-
isSubscript
public boolean isSubscript()
- Returns:
- whether a run of text will be formatted as a superscript text. Default is false.
-
getTextCap
public TextCap getTextCap()
- Returns:
- whether a run of text will be formatted as a superscript text. Default is false.
-
setBold
public void setBold(boolean bold)
Specifies whether this run of text will be formatted as bold text- Parameters:
bold
- whether this run of text will be formatted as bold text
-
isBold
public boolean isBold()
- Returns:
- whether this run of text is formatted as bold text
-
setItalic
public void setItalic(boolean italic)
- Parameters:
italic
- whether this run of text is formatted as italic text
-
isItalic
public boolean isItalic()
- Returns:
- whether this run of text is formatted as italic text
-
setUnderline
public void setUnderline(boolean underline)
- Parameters:
underline
- whether this run of text is formatted as underlined text
-
isUnderline
public boolean isUnderline()
- Returns:
- whether this run of text is formatted as underlined text
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
-