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

public final Class HSSFCellStyle

extends Object
implements CellStyle, Duplicatable
Class Inheritance
All Implemented Interfaces
org.apache.poi.common.Duplicatable, org.apache.poi.ss.usermodel.CellStyle
Imports
java.util.List, .Objects, org.apache.poi.common.Duplicatable, org.apache.poi.hssf.model.InternalWorkbook, org.apache.poi.hssf.record.ExtendedFormatRecord, .FontRecord, .FormatRecord, .StyleRecord, org.apache.poi.hssf.util.HSSFColor, .HSSFColor.HSSFColorPredefined, org.apache.poi.ss.usermodel.BorderStyle, .CellStyle, .FillPatternType, .Font, .HorizontalAlignment, .VerticalAlignment, org.apache.poi.util.Removal, .ThreadLocalUtil

High level representation of the style of a cell in a sheet of a workbook.
See Also
org.apache.poi.hssf.usermodel.HSSFWorkbook#createCellStyle(), org.apache.poi.hssf.usermodel.HSSFWorkbook#getCellStyleAt(int), org.apache.poi.hssf.usermodel.HSSFCell#setCellStyle(HSSFCellStyle)

Field Summary

Modifier and TypeField and Description
private final ExtendedFormatRecord
private final short
private final InternalWorkbook
private static final ThreadLocal<String>
private static final ThreadLocal<Short>
private static final ThreadLocal<List<FormatRecord>>

Constructor Summary

AccessConstructor and Description
protected
HSSFCellStyle(short index, ExtendedFormatRecord rec, HSSFWorkbook workbook)

Creates new HSSFCellStyle why would you want to do this??

protected
protected

Method Summary

Modifier and TypeMethod and Description
private void
checkDefaultBackgroundFills()

Checks if the background and foreground fills are set correctly when one or the other is set to the default color.

public void
cloneStyleFrom(CellStyle source)

Implements org.apache.poi.ss.usermodel.CellStyle.cloneStyleFrom.

Clones all the style information from another HSSFCellStyle, onto this one.

public void
public HSSFCellStyle
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 HorizontalAlignment
getAlignment()

Implements org.apache.poi.ss.usermodel.CellStyle.getAlignment.

get the type of horizontal alignment for the cell

public BorderStyle
getBorderBottom()

Implements org.apache.poi.ss.usermodel.CellStyle.getBorderBottom.

get the type of border to use for the bottom border of the cell

public BorderStyle
getBorderLeft()

Implements org.apache.poi.ss.usermodel.CellStyle.getBorderLeft.

get the type of border to use for the left border of the cell

public BorderStyle
getBorderRight()

Implements org.apache.poi.ss.usermodel.CellStyle.getBorderRight.

get the type of border to use for the right border of the cell

public BorderStyle
getBorderTop()

Implements org.apache.poi.ss.usermodel.CellStyle.getBorderTop.

get the type of border to use for the top border of the cell

public short

Returns:

The index of the color definition
getBottomBorderColor
()

Implements org.apache.poi.ss.usermodel.CellStyle.getBottomBorderColor.

get the color to use for the left border

public short
getDataFormat()

Implements org.apache.poi.ss.usermodel.CellStyle.getDataFormat.

get the index of the format

public String

Returns:

the format string or "General" if not found
getDataFormatString
()

Implements org.apache.poi.ss.usermodel.CellStyle.getDataFormatString.

Get the contents of the format string, by looking up the DataFormat against the bound workbook

public String

Returns:

the format string or "General" if not found
getDataFormatString
(Workbook workbook)

Get the contents of the format string, by looking up the DataFormat against the supplied workbook

public String
getDataFormatString(InternalWorkbook workbook)

Get the contents of the format string, by looking up the DataFormat against the supplied low level workbook

public short

Returns:

fill color
getFillBackgroundColor
()

Implements org.apache.poi.ss.usermodel.CellStyle.getFillBackgroundColor.

Get the background fill color.

public HSSFColor
getFillBackgroundColorColor()

Implements org.apache.poi.ss.usermodel.CellStyle.getFillBackgroundColorColor.

Gets the color object representing the current background fill, resolving indexes using the supplied workbook.

public short

Returns:

fill color
getFillForegroundColor
()

Implements org.apache.poi.ss.usermodel.CellStyle.getFillForegroundColor.

Get the foreground fill color.

public HSSFColor
getFillForegroundColorColor()

Implements org.apache.poi.ss.usermodel.CellStyle.getFillForegroundColorColor.

Gets the color object representing the current foreground fill, resolving indexes using the supplied workbook.

public FillPatternType
public HSSFFont
getFont(Workbook
The HSSFWorkbook that this style belongs to
parentWorkbook
)

gets the font for this style

public int
getFontIndex()

Implements org.apache.poi.ss.usermodel.CellStyle.getFontIndex.

gets the index of the font for this style

public int
getFontIndexAsInt()

Implements org.apache.poi.ss.usermodel.CellStyle.getFontIndexAsInt.

Deprecated use getFontIndex() instead

gets the index of the font for this style

public boolean

Returns:

hidden - whether the cell using this style should be hidden
getHidden
()

Implements org.apache.poi.ss.usermodel.CellStyle.getHidden.

get whether the cell's using this style are to be hidden

public short

Returns:

indent - number of spaces
getIndention
()

Implements org.apache.poi.ss.usermodel.CellStyle.getIndention.

get the number of spaces to indent the text in the cell

public short

Returns:

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

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

get the index within the HSSFWorkbook (sequence within the collection of ExtendedFormat objects)

public short

Returns:

The index of the color definition
getLeftBorderColor
()

Implements org.apache.poi.ss.usermodel.CellStyle.getLeftBorderColor.

get the color to use for the left border

public boolean

Returns:

hidden - whether the cell using this style should be locked
getLocked
()

Implements org.apache.poi.ss.usermodel.CellStyle.getLocked.

get whether the cell's using this style are to be locked

public HSSFCellStyle
getParentStyle()

Return the parent style for this cell style.

public boolean
getQuotePrefixed()

Implements org.apache.poi.ss.usermodel.CellStyle.getQuotePrefixed.

Is "Quote Prefix" or "123 Prefix" enabled for the cell?

public short

Returns:

order - the reading order (0,1,2)
getReadingOrder
()

Get the reading order, for RTL/LTR ordering of the text.

public short

Returns:

The index of the color definition
getRightBorderColor
()

Implements org.apache.poi.ss.usermodel.CellStyle.getRightBorderColor.

get the color to use for the left border

public short

Returns:

rotation degrees (between -90 and 90 degrees, or 0xff for vertical)
getRotation
()

Implements org.apache.poi.ss.usermodel.CellStyle.getRotation.

get the degree of rotation for the text in the cell

public boolean
getShrinkToFit()

Implements org.apache.poi.ss.usermodel.CellStyle.getShrinkToFit.

Should the Cell be auto-sized by Excel to shrink it to fit if this text is too long?

public short

Returns:

The index of the color definition
getTopBorderColor
()

Implements org.apache.poi.ss.usermodel.CellStyle.getTopBorderColor.

get the color to use for the top border

public String
getUserStyleName()

Gets the name of the user defined style.

public VerticalAlignment
getVerticalAlignment()

Implements org.apache.poi.ss.usermodel.CellStyle.getVerticalAlignment.

get the type of vertical alignment for the cell

public boolean

Returns:

wrap text or not
getWrapText
()

Implements org.apache.poi.ss.usermodel.CellStyle.getWrapText.

get whether the text should be wrapped

public int
hashCode()

Overrides java.lang.Object.hashCode.

Returns a hash code value for this object.

public void
setAlignment(HorizontalAlignment
- the type of alignment
align
)

Implements org.apache.poi.ss.usermodel.CellStyle.setAlignment.

set the type of horizontal alignment for the cell

public void
setBorderBottom(BorderStyle
type
border
)

Implements org.apache.poi.ss.usermodel.CellStyle.setBorderBottom.

set the type of border to use for the bottom border of the cell

public void
setBorderLeft(BorderStyle
type
border
)

Implements org.apache.poi.ss.usermodel.CellStyle.setBorderLeft.

set the type of border to use for the left border of the cell

public void
setBorderRight(BorderStyle
type
border
)

Implements org.apache.poi.ss.usermodel.CellStyle.setBorderRight.

set the type of border to use for the right border of the cell

public void
setBorderTop(BorderStyle
type
border
)

Implements org.apache.poi.ss.usermodel.CellStyle.setBorderTop.

set the type of border to use for the top border of the cell

public void
setBottomBorderColor(short
The index of the color definition
color
)

Implements org.apache.poi.ss.usermodel.CellStyle.setBottomBorderColor.

set the color to use for the bottom border

public void
setDataFormat(short fmt)

Implements org.apache.poi.ss.usermodel.CellStyle.setDataFormat.

set the data format (must be a valid format)

public void
setFillBackgroundColor(short
color
bg
)

Implements org.apache.poi.ss.usermodel.CellStyle.setFillBackgroundColor.

set the background fill color.

public void
setFillBackgroundColor(Color
the color to use
color
)

Implements org.apache.poi.ss.usermodel.CellStyle.setFillBackgroundColor.

Set the background fill color represented as a org.apache.poi.ss.usermodel.Color value.

public void
setFillForegroundColor(short
color
bg
)

Implements org.apache.poi.ss.usermodel.CellStyle.setFillForegroundColor.

set the foreground fill color

Note

Ensure Foreground color is set prior to background color.

public void
setFillForegroundColor(Color
the color to use
color
)

Implements org.apache.poi.ss.usermodel.CellStyle.setFillForegroundColor.

Set the foreground fill color represented as a org.apache.poi.ss.usermodel.Color value.

public void
setFillPattern(FillPatternType
fill pattern (set to FillPatternType#SOLID_FOREGROUND to fill w/foreground color)
fp
)

Implements org.apache.poi.ss.usermodel.CellStyle.setFillPattern.

setting to one fills the cell with the foreground color...

public void
setFont(Font
a font object created or retrieved from the HSSFWorkbook object
font
)

Implements org.apache.poi.ss.usermodel.CellStyle.setFont.

set the font for this style

public void
public void
setHidden(boolean
- whether the cell using this style should be hidden
hidden
)

Implements org.apache.poi.ss.usermodel.CellStyle.setHidden.

set the cell's using this style to be hidden

public void
setIndention(short
- number of spaces
indent
)

Implements org.apache.poi.ss.usermodel.CellStyle.setIndention.

set the number of spaces to indent the text in the cell

public void
setLeftBorderColor(short
The index of the color definition
color
)

Implements org.apache.poi.ss.usermodel.CellStyle.setLeftBorderColor.

set the color to use for the left border

public void
setLocked(boolean
- whether the cell using this style should be locked
locked
)

Implements org.apache.poi.ss.usermodel.CellStyle.setLocked.

set the cell's using this style to be locked

public void
setQuotePrefixed(boolean quotePrefix)

Implements org.apache.poi.ss.usermodel.CellStyle.setQuotePrefixed.

Turn on or off "Quote Prefix" or "123 Prefix" for the style, which is used to tell Excel that the thing which looks like a number or a formula shouldn't be treated as on.

public void
setReadingOrder(short
- the reading order (0,1,2)
order
)

Sets the reading order, for RTL/LTR ordering of the text.

public void
setRightBorderColor(short
The index of the color definition
color
)

Implements org.apache.poi.ss.usermodel.CellStyle.setRightBorderColor.

set the color to use for the right border

public void
setRotation(short
degrees (between -90 and 90 degrees, of 0xff for vertical)
rotation
)

Implements org.apache.poi.ss.usermodel.CellStyle.setRotation.

set the degree of rotation for the text in the cell Note: HSSF uses values from -90 to 90 degrees, whereas XSSF uses values from 0 to 180 degrees.

public void
setShrinkToFit(boolean shrinkToFit)

Implements org.apache.poi.ss.usermodel.CellStyle.setShrinkToFit.

Controls if the Cell should be auto-sized to shrink to fit if the text is too long

public void
setTopBorderColor(short
The index of the color definition
color
)

Implements org.apache.poi.ss.usermodel.CellStyle.setTopBorderColor.

set the color to use for the top border

public void
setUserStyleName(String styleName)

Sets the name of the user defined style.

public void
setVerticalAlignment(VerticalAlignment
the type of alignment
align
)

Implements org.apache.poi.ss.usermodel.CellStyle.setVerticalAlignment.

set the type of vertical alignment for the cell

public void
setWrapText(boolean
wrap text or not
wrapped
)

Implements org.apache.poi.ss.usermodel.CellStyle.setWrapText.

set whether the text should be wrapped

public void
verifyBelongsToWorkbook(HSSFWorkbook wb)

Verifies that this style belongs to the supplied Workbook.

Inherited from java.lang.Object:
clonefinalizegetClassnotifynotifyAlltoStringwaitwaitwait