Package org.apache.poi.xssf.usermodel
Class XSSFFont
java.lang.Object
org.apache.poi.xssf.usermodel.XSSFFont
- All Implemented Interfaces:
Font
Represents a font used in a workbook.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final short
Default font color is blackstatic final String
By default, Microsoft Office Excel 2007 uses the Calibri font in font size 11static final short
By default, Microsoft Office Excel 2007 uses the Calibri font in font size 11Fields inherited from interface org.apache.poi.ss.usermodel.Font
ANSI_CHARSET, COLOR_NORMAL, COLOR_RED, DEFAULT_CHARSET, SS_NONE, SS_SUB, SS_SUPER, SYMBOL_CHARSET, TWIPS_PER_POINT, U_DOUBLE, U_DOUBLE_ACCOUNTING, U_NONE, U_SINGLE, U_SINGLE_ACCOUNTING
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionboolean
boolean
getBold()
get a boolean value for the boldness to use.int
get character-set to use.short
getColor()
get the indexed color value for the font References a color defined in IndexedColors.get the underlying CTFont fontint
get the font family to use.short
Get the font height in unit's of 1/20th of a point.short
Get the font height in points.get the name of the font (i.e.int
getIndex()
get the index within the XSSFWorkbook (sequence within the collection of Font objects)int
Deprecated.boolean
get a boolean value that specify whether to use italics or notget the font scheme property.boolean
get a boolean value that specify whether to use a strikeout horizontal line through the text or notshort
get the color value for the font References a color defined in theme.short
get normal,super or subscript.byte
get type of text underlining to useget the color value for the font References a color defined as Standard Alpha Red Green Blue color value (ARGB).int
hashCode()
long
registerTo
(StylesTable styles) Perform a registration of ourselves to the style tablelong
registerTo
(StylesTable styles, boolean force) void
setBold
(boolean bold) set a boolean value for the boldness to use.void
setCharSet
(byte charset) set character-set to use.void
setCharSet
(int charset) set character-set to use.void
setCharSet
(FontCharset charSet) set character-set to use.void
setCharSet
(FontCharset charSet) Deprecated.usesetCharSet(FontCharset)
insteadvoid
setColor
(short color) set the indexed color for the fontvoid
set the color for the font in Standard Alpha Red Green Blue color valuevoid
setFamily
(int value) Set the font family this font belongs to.void
setFamily
(FontFamily family) set an enumeration representing the font family this font belongs to.void
setFontHeight
(double height) set the font height in points.void
setFontHeight
(short height) set the font height in points.void
setFontHeightInPoints
(short height) set the font height in points.void
setFontName
(String name) set the name for the font (i.e.void
setItalic
(boolean italic) set a boolean value for the property specifying whether to use italics or not If omitted, the default value is true.void
setScheme
(FontScheme scheme) set font scheme propertyvoid
setStrikeout
(boolean strikeout) set a boolean value for the property specifying whether to use a strikeout horizontal line through the text or not If omitted, the default value is true.void
setThemeColor
(short theme) set the theme color for the font to usevoid
setThemesTable
(ThemesTable themes) Records the Themes Table that is associated with the current font, used when looking up theme based colours and properties.void
setTypeOffset
(short offset) set normal,super or subscript, that representing the vertical-alignment setting.void
setUnderline
(byte underline) set the style of underlining that is used.void
setUnderline
(FontUnderline underline) set an enumeration representing the style of underlining that is used.toString()
-
Field Details
-
DEFAULT_FONT_NAME
By default, Microsoft Office Excel 2007 uses the Calibri font in font size 11- See Also:
-
DEFAULT_FONT_SIZE
public static final short DEFAULT_FONT_SIZEBy default, Microsoft Office Excel 2007 uses the Calibri font in font size 11- See Also:
-
DEFAULT_FONT_COLOR
public static final short DEFAULT_FONT_COLORDefault font color is black- See Also:
-
-
Constructor Details
-
XSSFFont
Create a new XSSFFont- Parameters:
font
- the underlying CTFont bean
-
XSSFFont
Called from parsing styles.xml- Parameters:
font
- CTFontindex
- font indexcolorMap
- for default or custom indexed colors
-
XSSFFont
public XSSFFont()Create a new XSSFont. This method is protected to be used only by XSSFWorkbook
-
-
Method Details
-
getCTFont
get the underlying CTFont font -
getBold
public boolean getBold()get a boolean value for the boldness to use. -
getCharSet
public int getCharSet()get character-set to use.- Specified by:
getCharSet
in interfaceFont
- Returns:
- int - character-set (0-255)
- See Also:
-
getColor
public short getColor()get the indexed color value for the font References a color defined in IndexedColors. -
getXSSFColor
get the color value for the font References a color defined as Standard Alpha Red Green Blue color value (ARGB).- Returns:
- XSSFColor - rgb color to use
-
getThemeColor
public short getThemeColor()get the color value for the font References a color defined in theme.- Returns:
- short - theme defined to use
-
getFontHeight
public short getFontHeight()Get the font height in unit's of 1/20th of a point.For many users, the related
getFontHeightInPoints()
will be more helpful, as that returns font heights in the more familiar points units, eg 10, 12, 14.- Specified by:
getFontHeight
in interfaceFont
- Returns:
- short - height in 1/20ths of a point
- See Also:
-
getFontHeightInPoints
public short getFontHeightInPoints()Get the font height in points.This will return the same font height that is shown in Excel, such as 10 or 14 or 28.
- Specified by:
getFontHeightInPoints
in interfaceFont
- Returns:
- short - height in the familiar unit of measure - points
- See Also:
-
getFontName
get the name of the font (i.e. Arial)- Specified by:
getFontName
in interfaceFont
- Returns:
- String - a string representing the name of the font to use
-
getItalic
public boolean getItalic()get a boolean value that specify whether to use italics or not -
getStrikeout
public boolean getStrikeout()get a boolean value that specify whether to use a strikeout horizontal line through the text or not- Specified by:
getStrikeout
in interfaceFont
- Returns:
- boolean - value for strikeout
-
getTypeOffset
public short getTypeOffset()get normal,super or subscript.- Specified by:
getTypeOffset
in interfaceFont
- Returns:
- short - offset type to use (none,super,sub)
- See Also:
-
getUnderline
public byte getUnderline()get type of text underlining to use- Specified by:
getUnderline
in interfaceFont
- Returns:
- byte - underlining type
- See Also:
-
setBold
public void setBold(boolean bold) set a boolean value for the boldness to use. If omitted, the default value is true. -
setCharSet
public void setCharSet(byte charset) set character-set to use.- Specified by:
setCharSet
in interfaceFont
- Parameters:
charset
- - charset- See Also:
-
setCharSet
public void setCharSet(int charset) set character-set to use.- Specified by:
setCharSet
in interfaceFont
- Parameters:
charset
- - charset- See Also:
-
setCharSet
Deprecated.usesetCharSet(FontCharset)
insteadset character-set to use. -
setCharSet
set character-set to use.- Since:
- 5.0.0
-
setColor
public void setColor(short color) set the indexed color for the font -
setColor
set the color for the font in Standard Alpha Red Green Blue color value- Parameters:
color
- - color to use
-
setFontHeight
public void setFontHeight(short height) set the font height in points.- Specified by:
setFontHeight
in interfaceFont
- Parameters:
height
- - height in points- See Also:
-
setFontHeight
public void setFontHeight(double height) set the font height in points.- Parameters:
height
- - height in points
-
setFontHeightInPoints
public void setFontHeightInPoints(short height) set the font height in points.- Specified by:
setFontHeightInPoints
in interfaceFont
- Parameters:
height
- height in the familiar unit of measure - points- See Also:
-
setThemeColor
public void setThemeColor(short theme) set the theme color for the font to use- Parameters:
theme
- - theme color to use
-
setFontName
set the name for the font (i.e. Arial). If the font doesn't exist (because it isn't installed on the system), or the charset is invalid for that font, then another font should be substituted. The string length for this attribute shall be 0 to 31 characters. Default font name is Calibri.- Specified by:
setFontName
in interfaceFont
- Parameters:
name
- - value representing the name of the font to use- See Also:
-
setItalic
public void setItalic(boolean italic) set a boolean value for the property specifying whether to use italics or not If omitted, the default value is true. -
setStrikeout
public void setStrikeout(boolean strikeout) set a boolean value for the property specifying whether to use a strikeout horizontal line through the text or not If omitted, the default value is true.- Specified by:
setStrikeout
in interfaceFont
- Parameters:
strikeout
- - value for strikeout or not
-
setTypeOffset
public void setTypeOffset(short offset) set normal,super or subscript, that representing the vertical-alignment setting. Setting this to either subscript or superscript shall make the font size smaller if a smaller font size is available.- Specified by:
setTypeOffset
in interfaceFont
- Parameters:
offset
- - offset type to use (none,super,sub)- See Also:
-
setUnderline
public void setUnderline(byte underline) set the style of underlining that is used. The none style is equivalent to not using underlining at all.- Specified by:
setUnderline
in interfaceFont
- Parameters:
underline
- - underline type to use- See Also:
-
setUnderline
set an enumeration representing the style of underlining that is used. The none style is equivalent to not using underlining at all. The possible values for this attribute are defined by the FontUnderline- Parameters:
underline
- - FontUnderline enum value
-
toString
-
registerTo
Perform a registration of ourselves to the style table -
registerTo
-
setThemesTable
Records the Themes Table that is associated with the current font, used when looking up theme based colours and properties. -
getScheme
get the font scheme property. is used only in StylesTable to create the default instance of font- Returns:
- FontScheme
- See Also:
-
setScheme
set font scheme property- Parameters:
scheme
- - FontScheme enum value- See Also:
-
getFamily
public int getFamily()get the font family to use.- Returns:
- the font family to use
- See Also:
-
setFamily
public void setFamily(int value) Set the font family this font belongs to. A font family is a set of fonts having common stroke width and serif characteristics. The font name overrides when there are conflicting values.- Parameters:
value
- - font family- See Also:
-
setFamily
set an enumeration representing the font family this font belongs to. A font family is a set of fonts having common stroke width and serif characteristics.- Parameters:
family
- font family- See Also:
-
getIndex
public int getIndex()Description copied from interface:Font
get the index within the XSSFWorkbook (sequence within the collection of Font objects) -
getIndexAsInt
Deprecated.usegetIndex()
insteadDescription copied from interface:Font
get the index within the XSSFWorkbook (sequence within the collection of Font objects)- Specified by:
getIndexAsInt
in interfaceFont
- Returns:
- index
-
hashCode
public int hashCode() -
equals
-
getIndex()
instead