Top Description Fields Constructors Methods
org.apache.poi.hssf.usermodel

public final Class HSSFFont

extends Object
implements Font
Class Inheritance
All Implemented Interfaces
org.apache.poi.ss.usermodel.Font
Imports
java.util.Objects, org.apache.poi.hssf.record.FontRecord, org.apache.poi.hssf.util.HSSFColor, org.apache.poi.ss.usermodel.Font, org.apache.poi.util.Removal

Represents a Font used in a workbook.
See Also
org.apache.poi.hssf.usermodel.HSSFWorkbook#createFont(), org.apache.poi.hssf.usermodel.HSSFWorkbook#getFontAt(int), org.apache.poi.hssf.usermodel.HSSFCellStyle#setFont(HSSFFont)

Field Summary

Modifier and TypeField and Description
pack-priv static final short
BOLDWEIGHT_BOLD

Bold boldness (bold)

pack-priv static final short
BOLDWEIGHT_NORMAL

Normal boldness (not bold)

private final FontRecord
public static final String
FONT_ARIAL

Arial font

private final int

Constructor Summary

AccessConstructor and Description
protected
HSSFFont(int index, FontRecord rec)

Creates a new instance of HSSFFont

Method Summary

Modifier and TypeMethod and Description
public boolean
equals(Object
the reference object with which to compare.
obj
)

Overrides java.lang.Object.equals.

Indicates whether some other object is "equal to" this one.

public boolean
getBold()

Implements org.apache.poi.ss.usermodel.Font.getBold.

get if the font is bold or not

public int

Returns:

character-set
getCharSet
()

Implements org.apache.poi.ss.usermodel.Font.getCharSet.

get character-set to use.

public short

Returns:

color to use
getColor
()

Implements org.apache.poi.ss.usermodel.Font.getColor.

get the color for the font

public short

Returns:

short - height in 1/20ths of a point
getFontHeight
()

Implements org.apache.poi.ss.usermodel.Font.getFontHeight.

get the font height in unit's of 1/20th of a point.

public short

Returns:

short - height in the familiar unit of measure - points
getFontHeightInPoints
()

Implements org.apache.poi.ss.usermodel.Font.getFontHeightInPoints.

get the font height

public String

Returns:

String representing the name of the font to use
getFontName
()

Implements org.apache.poi.ss.usermodel.Font.getFontName.

get the name for the font (i.e. Arial)

public HSSFColor
getHSSFColor(HSSFWorkbook wb)

get the color value for the font

public int
getIndex()

Implements org.apache.poi.ss.usermodel.Font.getIndex.

get the index within the XSSFWorkbook (sequence within the collection of Font objects)

public int
getIndexAsInt()

Implements org.apache.poi.ss.usermodel.Font.getIndexAsInt.

Deprecated

get the index within the XSSFWorkbook (sequence within the collection of Font objects)

public boolean

Returns:

italics or not
getItalic
()

Implements org.apache.poi.ss.usermodel.Font.getItalic.

get whether to use italics or not

public boolean

Returns:

strikeout or not
getStrikeout
()

Implements org.apache.poi.ss.usermodel.Font.getStrikeout.

get whether to use a strikeout horizontal line through the text or not

public short

Returns:

offset type to use (none,super,sub)
getTypeOffset
()

Implements org.apache.poi.ss.usermodel.Font.getTypeOffset.

get normal,super or subscript.

public byte

Returns:

underlining type
getUnderline
()

Implements org.apache.poi.ss.usermodel.Font.getUnderline.

get type of text underlining to use

public int
hashCode()

Overrides java.lang.Object.hashCode.

Returns a hash code value for this object.

public void
setBold(boolean bold)

Implements org.apache.poi.ss.usermodel.Font.setBold.

sets the font to be bold or not

public void
setCharSet(int charset)

Implements org.apache.poi.ss.usermodel.Font.setCharSet.

set character-set to use.

public void
setCharSet(byte charset)

Implements org.apache.poi.ss.usermodel.Font.setCharSet.

set character-set to use.

public void
setColor(short
to use
color
)

Implements org.apache.poi.ss.usermodel.Font.setColor.

set the color for the font

public void
setFontHeight(short
height in 1/20ths of a point
height
)

Implements org.apache.poi.ss.usermodel.Font.setFontHeight.

set the font height in unit's of 1/20th of a point.

public void
setFontHeightInPoints(short
height in the familiar unit of measure - points
height
)

Implements org.apache.poi.ss.usermodel.Font.setFontHeightInPoints.

set the font height

public void
setFontName(String
String representing the name of the font to use
name
)

Implements org.apache.poi.ss.usermodel.Font.setFontName.

set the name for the font (i.e. Arial)

public void
setItalic(boolean
italics or not
italic
)

Implements org.apache.poi.ss.usermodel.Font.setItalic.

set whether to use italics or not

public void
setStrikeout(boolean
or not
strikeout
)

Implements org.apache.poi.ss.usermodel.Font.setStrikeout.

set whether to use a strikeout horizontal line through the text or not

public void
setTypeOffset(short
type to use (none,super,sub)
offset
)

Implements org.apache.poi.ss.usermodel.Font.setTypeOffset.

set normal,super or subscript.

public void
setUnderline(byte
type
underline
)

Implements org.apache.poi.ss.usermodel.Font.setUnderline.

set type of text underlining to use

public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.

Inherited from java.lang.Object:
clonefinalizegetClassnotifynotifyAllwaitwaitwait

Field Detail

BOLDWEIGHT_BOLDback to summary
pack-priv static final short BOLDWEIGHT_BOLD

Bold boldness (bold)

BOLDWEIGHT_NORMALback to summary
pack-priv static final short BOLDWEIGHT_NORMAL

Normal boldness (not bold)

fontback to summary
private final FontRecord font
FONT_ARIALback to summary
public static final String FONT_ARIAL

Arial font

indexback to summary
private final int index

Constructor Detail

HSSFFontback to summary
protected HSSFFont(int index, FontRecord rec)

Creates a new instance of HSSFFont

Method Detail

equalsback to summary
public boolean equals(Object obj)

Overrides java.lang.Object.equals.

Doc from java.lang.Object.equals.

Indicates whether some other object is "equal to" this one.

The equals method implements an equivalence relation on non-null object references:

  • It is reflexive: for any non-null reference value x, x.equals(x) should return true.
  • It is symmetric: for any non-null reference values x and y, x.equals(y) should return true if and only if y.equals(x) returns true.
  • It is transitive: for any non-null reference values x, y, and z, if x.equals(y) returns true and y.equals(z) returns true, then x.equals(z) should return true.
  • It is consistent: for any non-null reference values x and y, multiple invocations of x.equals(y) consistently return true or consistently return false, provided no information used in equals comparisons on the objects is modified.
  • For any non-null reference value x, x.equals(null) should return false.

An equivalence relation partitions the elements it operates on into equivalence classes; all the members of an equivalence class are equal to each other. Members of an equivalence class are substitutable for each other, at least for some purposes.

Parameters
obj:Object

the reference object with which to compare.

Returns:boolean

true if this object is the same as the obj argument; false otherwise.

getBoldback to summary
public boolean getBold()

Implements org.apache.poi.ss.usermodel.Font.getBold.

get if the font is bold or not

Annotations
@Override
getCharSetback to summary
public int getCharSet()

Implements org.apache.poi.ss.usermodel.Font.getCharSet.

get character-set to use.

Returns:int

character-set

Annotations
@Override
See Also
ANSI_CHARSET, DEFAULT_CHARSET, SYMBOL_CHARSET
getColorback to summary
public short getColor()

Implements org.apache.poi.ss.usermodel.Font.getColor.

get the color for the font

Returns:short

color to use

Annotations
@Override
See Also
COLOR_NORMAL, COLOR_RED, org.apache.poi.hssf.usermodel.HSSFPalette#getColor(short)
getFontHeightback to summary
public short getFontHeight()

Implements org.apache.poi.ss.usermodel.Font.getFontHeight.

get the font height in unit's of 1/20th of a point. Maybe you might want to use the getFontHeightInPoints which matches to the familiar 10, 12, 14 etc..

Returns:short

short - height in 1/20ths of a point

Annotations
@Override
See Also
getFontHeightInPoints()
getFontHeightInPointsback to summary
public short getFontHeightInPoints()

Implements org.apache.poi.ss.usermodel.Font.getFontHeightInPoints.

get the font height

Returns:short

short - height in the familiar unit of measure - points

Annotations
@Override
See Also
getFontHeight()
getFontNameback to summary
public String getFontName()

Implements org.apache.poi.ss.usermodel.Font.getFontName.

get the name for the font (i.e. Arial)

Returns:String

String representing the name of the font to use

Annotations
@Override
See Also
FONT_ARIAL
getHSSFColorback to summary
public HSSFColor getHSSFColor(HSSFWorkbook wb)

get the color value for the font

getIndexback to summary
public int getIndex()

Implements org.apache.poi.ss.usermodel.Font.getIndex.

Doc from org.apache.poi.ss.usermodel.Font.getIndex.

get the index within the XSSFWorkbook (sequence within the collection of Font objects)

Returns:int

unique index number of the underlying record this Font represents (probably you don't care unless you're comparing which one is which)

Annotations
@Override
getIndexAsIntback to summary
public int getIndexAsInt()

Implements org.apache.poi.ss.usermodel.Font.getIndexAsInt.

Doc from org.apache.poi.ss.usermodel.Font.getIndexAsInt.

Deprecated

get the index within the XSSFWorkbook (sequence within the collection of Font objects)

Returns:int

unique index number of the underlying record this Font represents (probably you don't care unless you're comparing which one is which)

Annotations
@Deprecated
@Removal
version:6.0.0
@Override
getItalicback to summary
public boolean getItalic()

Implements org.apache.poi.ss.usermodel.Font.getItalic.

get whether to use italics or not

Returns:boolean

italics or not

Annotations
@Override
getStrikeoutback to summary
public boolean getStrikeout()

Implements org.apache.poi.ss.usermodel.Font.getStrikeout.

get whether to use a strikeout horizontal line through the text or not

Returns:boolean

strikeout or not

Annotations
@Override
getTypeOffsetback to summary
public short getTypeOffset()

Implements org.apache.poi.ss.usermodel.Font.getTypeOffset.

get normal,super or subscript.

Returns:short

offset type to use (none,super,sub)

Annotations
@Override
See Also
SS_NONE, SS_SUPER, SS_SUB
getUnderlineback to summary
public byte getUnderline()

Implements org.apache.poi.ss.usermodel.Font.getUnderline.

get type of text underlining to use

Returns:byte

underlining type

Annotations
@Override
See Also
U_NONE, U_SINGLE, U_DOUBLE, U_SINGLE_ACCOUNTING, U_DOUBLE_ACCOUNTING
hashCodeback to summary
public int hashCode()

Overrides java.lang.Object.hashCode.

Doc from java.lang.Object.hashCode.

Returns a hash code value for this object. This method is supported for the benefit of hash tables such as those provided by java.util.HashMap.

The general contract of hashCode is:

  • Whenever it is invoked on the same object more than once during an execution of a Java application, the hashCode method must consistently return the same integer, provided no information used in equals comparisons on the object is modified. This integer need not remain consistent from one execution of an application to another execution of the same application.
  • If two objects are equal according to the equals method, then calling the hashCode method on each of the two objects must produce the same integer result.
  • It is not required that if two objects are unequal according to the equals method, then calling the hashCode method on each of the two objects must produce distinct integer results. However, the programmer should be aware that producing distinct integer results for unequal objects may improve the performance of hash tables.
Returns:int

a hash code value for this object

setBoldback to summary
public void setBold(boolean bold)

Implements org.apache.poi.ss.usermodel.Font.setBold.

sets the font to be bold or not

Annotations
@Override
setCharSetback to summary
public void setCharSet(int charset)

Implements org.apache.poi.ss.usermodel.Font.setCharSet.

set character-set to use.

Annotations
@Override
See Also
ANSI_CHARSET, DEFAULT_CHARSET, SYMBOL_CHARSET
setCharSetback to summary
public void setCharSet(byte charset)

Implements org.apache.poi.ss.usermodel.Font.setCharSet.

set character-set to use.

Annotations
@Override
See Also
ANSI_CHARSET, DEFAULT_CHARSET, SYMBOL_CHARSET
setColorback to summary
public void setColor(short color)

Implements org.apache.poi.ss.usermodel.Font.setColor.

set the color for the font

Parameters
color:short

to use

Annotations
@Override
See Also
Note: Use this rather than HSSFColor.AUTOMATIC for default font color, COLOR_RED
setFontHeightback to summary
public void setFontHeight(short height)

Implements org.apache.poi.ss.usermodel.Font.setFontHeight.

set the font height in unit's of 1/20th of a point. Maybe you might want to use the setFontHeightInPoints which matches to the familiar 10, 12, 14 etc..

Parameters
height:short

height in 1/20ths of a point

Annotations
@Override
See Also
setFontHeightInPoints(short)
setFontHeightInPointsback to summary
public void setFontHeightInPoints(short height)

Implements org.apache.poi.ss.usermodel.Font.setFontHeightInPoints.

set the font height

Parameters
height:short

height in the familiar unit of measure - points

Annotations
@Override
See Also
setFontHeight(short)
setFontNameback to summary
public void setFontName(String name)

Implements org.apache.poi.ss.usermodel.Font.setFontName.

set the name for the font (i.e. Arial)

Parameters
name:String

String representing the name of the font to use

Annotations
@Override
See Also
FONT_ARIAL
setItalicback to summary
public void setItalic(boolean italic)

Implements org.apache.poi.ss.usermodel.Font.setItalic.

set whether to use italics or not

Parameters
italic:boolean

italics or not

Annotations
@Override
setStrikeoutback to summary
public void setStrikeout(boolean strikeout)

Implements org.apache.poi.ss.usermodel.Font.setStrikeout.

set whether to use a strikeout horizontal line through the text or not

Parameters
strikeout:boolean

or not

Annotations
@Override
setTypeOffsetback to summary
public void setTypeOffset(short offset)

Implements org.apache.poi.ss.usermodel.Font.setTypeOffset.

set normal,super or subscript.

Parameters
offset:short

type to use (none,super,sub)

Annotations
@Override
See Also
SS_NONE, SS_SUPER, SS_SUB
setUnderlineback to summary
public void setUnderline(byte underline)

Implements org.apache.poi.ss.usermodel.Font.setUnderline.

set type of text underlining to use

Parameters
underline:byte

type

Annotations
@Override
See Also
U_NONE, U_SINGLE, U_DOUBLE, U_SINGLE_ACCOUNTING, U_DOUBLE_ACCOUNTING
toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object. Satisfying this method's contract implies a non-null result must be returned.

Returns:String

a string representation of the object