Package loci.poi.hssf.usermodel
Class HSSFCellStyle
- java.lang.Object
-
- loci.poi.hssf.usermodel.HSSFCellStyle
-
public class HSSFCellStyle extends Object
High level representation of the style of a cell in a sheet of a workbook.- Version:
- 1.0-pre
- Author:
- Andrew C. Oliver (acoliver at apache dot org), Jason Height (jheight at chariot dot net dot au)
- See Also:
HSSFWorkbook.createCellStyle()
,HSSFWorkbook.getCellStyleAt(short)
,HSSFCell.setCellStyle(HSSFCellStyle)
-
-
Field Summary
Fields Modifier and Type Field Description static short
ALIGN_CENTER
center horizontal alignmentstatic short
ALIGN_CENTER_SELECTION
center-selection? horizontal alignmentstatic short
ALIGN_FILL
fill? horizontal alignmentstatic short
ALIGN_GENERAL
general (normal) horizontal alignmentstatic short
ALIGN_JUSTIFY
justified horizontal alignmentstatic short
ALIGN_LEFT
left-justified horizontal alignmentstatic short
ALIGN_RIGHT
right-justified horizontal alignmentstatic short
ALT_BARS
Wide dotsstatic short
BIG_SPOTS
Large spotsstatic short
BORDER_DASH_DOT
dash-dot borderstatic short
BORDER_DASH_DOT_DOT
dash-dot-dot borderstatic short
BORDER_DASHED
dash borderstatic short
BORDER_DOTTED
hair-line borderstatic short
BORDER_DOUBLE
double-line borderstatic short
BORDER_HAIR
dot borderstatic short
BORDER_MEDIUM
Medium borderstatic short
BORDER_MEDIUM_DASH_DOT
medium dash-dot borderstatic short
BORDER_MEDIUM_DASH_DOT_DOT
medium dash-dot-dot borderstatic short
BORDER_MEDIUM_DASHED
Medium dashed borderstatic short
BORDER_NONE
No borderstatic short
BORDER_SLANTED_DASH_DOT
slanted dash-dot borderstatic short
BORDER_THICK
Thick borderstatic short
BORDER_THIN
Thin borderstatic short
BRICKS
Brick-like layoutstatic short
DIAMONDS
Diamondsstatic short
FINE_DOTS
Small fine dotsstatic short
LEAST_DOTS
Least Dotsstatic short
LESS_DOTS
Less Dotsstatic short
NO_FILL
No backgroundstatic short
SOLID_FOREGROUND
Solidly filledstatic short
SPARSE_DOTS
Sparse dotsstatic short
SQUARES
Squaresstatic short
THICK_BACKWARD_DIAG
Thick backward facing diagonalsstatic short
THICK_FORWARD_DIAG
Thick forward facing diagonalsstatic short
THICK_HORZ_BANDS
Thick horizontal bandsstatic short
THICK_VERT_BANDS
Thick vertical bandsstatic short
THIN_BACKWARD_DIAG
Thin backward diagonalstatic short
THIN_FORWARD_DIAG
Thin forward diagonalstatic short
THIN_HORZ_BANDS
Thin horizontal bandsstatic short
THIN_VERT_BANDS
Thin vertical bandsstatic short
VERTICAL_BOTTOM
bottom-aligned vertical alignmentstatic short
VERTICAL_CENTER
center-aligned vertical alignmentstatic short
VERTICAL_JUSTIFY
vertically justified vertical alignmentstatic short
VERTICAL_TOP
top-aligned vertical alignment
-
Constructor Summary
Constructors Modifier Constructor Description protected
HSSFCellStyle(short index, ExtendedFormatRecord rec)
Creates new HSSFCellStyle why would you want to do this??
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description short
getAlignment()
get the type of horizontal alignment for the cellshort
getBorderBottom()
get the type of border to use for the bottom border of the cellshort
getBorderLeft()
get the type of border to use for the left border of the cellshort
getBorderRight()
get the type of border to use for the right border of the cellshort
getBorderTop()
get the type of border to use for the top border of the cellshort
getBottomBorderColor()
get the color to use for the left bordershort
getDataFormat()
get the index of the formatString
getDataFormatString(Workbook workbook)
Get the contents of the format string, by looking up the DataFormat against the supplied workbookshort
getFillBackgroundColor()
get the background fill colorshort
getFillForegroundColor()
get the foreground fill colorshort
getFillPattern()
get the fill pattern (??) - set to 1 to fill with foreground colorshort
getFontIndex()
boolean
getHidden()
get whether the cell's using this style are to be hiddenshort
getIndention()
get the number of spaces to indent the text in the cellshort
getIndex()
get the index within the HSSFWorkbook (sequence within the collection of ExtnededFormat objects)short
getLeftBorderColor()
get the color to use for the left borderboolean
getLocked()
get whether the cell's using this style are to be lockedshort
getRightBorderColor()
get the color to use for the left bordershort
getRotation()
get the degree of rotation for the text in the cellshort
getTopBorderColor()
get the color to use for the top bordershort
getVerticalAlignment()
get the type of vertical alignment for the cellboolean
getWrapText()
get whether the text should be wrappedvoid
setAlignment(short align)
set the type of horizontal alignment for the cellvoid
setBorderBottom(short border)
set the type of border to use for the bottom border of the cellvoid
setBorderLeft(short border)
set the type of border to use for the left border of the cellvoid
setBorderRight(short border)
set the type of border to use for the right border of the cellvoid
setBorderTop(short border)
set the type of border to use for the top border of the cellvoid
setBottomBorderColor(short color)
set the color to use for the bottom bordervoid
setDataFormat(short fmt)
set the data format (must be a valid format)void
setFillBackgroundColor(short bg)
set the background fill color.void
setFillForegroundColor(short bg)
set the foreground fill color Note: Ensure Foreground color is set prior to background color.void
setFillPattern(short fp)
setting to one fills the cell with the foreground color...void
setFont(HSSFFont font)
set the font for this stylevoid
setHidden(boolean hidden)
set the cell's using this style to be hiddenvoid
setIndention(short indent)
set the number of spaces to indent the text in the cellvoid
setLeftBorderColor(short color)
set the color to use for the left bordervoid
setLocked(boolean locked)
set the cell's using this style to be lockedvoid
setRightBorderColor(short color)
set the color to use for the right bordervoid
setRotation(short rotation)
set the degree of rotation for the text in the cellvoid
setTopBorderColor(short color)
set the color to use for the top bordervoid
setVerticalAlignment(short align)
set the type of vertical alignment for the cellvoid
setWrapText(boolean wrapped)
set whether the text should be wrapped
-
-
-
Field Detail
-
ALIGN_GENERAL
public static final short ALIGN_GENERAL
general (normal) horizontal alignment- See Also:
- Constant Field Values
-
ALIGN_LEFT
public static final short ALIGN_LEFT
left-justified horizontal alignment- See Also:
- Constant Field Values
-
ALIGN_CENTER
public static final short ALIGN_CENTER
center horizontal alignment- See Also:
- Constant Field Values
-
ALIGN_RIGHT
public static final short ALIGN_RIGHT
right-justified horizontal alignment- See Also:
- Constant Field Values
-
ALIGN_FILL
public static final short ALIGN_FILL
fill? horizontal alignment- See Also:
- Constant Field Values
-
ALIGN_JUSTIFY
public static final short ALIGN_JUSTIFY
justified horizontal alignment- See Also:
- Constant Field Values
-
ALIGN_CENTER_SELECTION
public static final short ALIGN_CENTER_SELECTION
center-selection? horizontal alignment- See Also:
- Constant Field Values
-
VERTICAL_TOP
public static final short VERTICAL_TOP
top-aligned vertical alignment- See Also:
- Constant Field Values
-
VERTICAL_CENTER
public static final short VERTICAL_CENTER
center-aligned vertical alignment- See Also:
- Constant Field Values
-
VERTICAL_BOTTOM
public static final short VERTICAL_BOTTOM
bottom-aligned vertical alignment- See Also:
- Constant Field Values
-
VERTICAL_JUSTIFY
public static final short VERTICAL_JUSTIFY
vertically justified vertical alignment- See Also:
- Constant Field Values
-
BORDER_NONE
public static final short BORDER_NONE
No border- See Also:
- Constant Field Values
-
BORDER_THIN
public static final short BORDER_THIN
Thin border- See Also:
- Constant Field Values
-
BORDER_MEDIUM
public static final short BORDER_MEDIUM
Medium border- See Also:
- Constant Field Values
-
BORDER_DASHED
public static final short BORDER_DASHED
dash border- See Also:
- Constant Field Values
-
BORDER_HAIR
public static final short BORDER_HAIR
dot border- See Also:
- Constant Field Values
-
BORDER_THICK
public static final short BORDER_THICK
Thick border- See Also:
- Constant Field Values
-
BORDER_DOUBLE
public static final short BORDER_DOUBLE
double-line border- See Also:
- Constant Field Values
-
BORDER_DOTTED
public static final short BORDER_DOTTED
hair-line border- See Also:
- Constant Field Values
-
BORDER_MEDIUM_DASHED
public static final short BORDER_MEDIUM_DASHED
Medium dashed border- See Also:
- Constant Field Values
-
BORDER_DASH_DOT
public static final short BORDER_DASH_DOT
dash-dot border- See Also:
- Constant Field Values
-
BORDER_MEDIUM_DASH_DOT
public static final short BORDER_MEDIUM_DASH_DOT
medium dash-dot border- See Also:
- Constant Field Values
-
BORDER_DASH_DOT_DOT
public static final short BORDER_DASH_DOT_DOT
dash-dot-dot border- See Also:
- Constant Field Values
-
BORDER_MEDIUM_DASH_DOT_DOT
public static final short BORDER_MEDIUM_DASH_DOT_DOT
medium dash-dot-dot border- See Also:
- Constant Field Values
-
BORDER_SLANTED_DASH_DOT
public static final short BORDER_SLANTED_DASH_DOT
slanted dash-dot border- See Also:
- Constant Field Values
-
NO_FILL
public static final short NO_FILL
No background- See Also:
- Constant Field Values
-
SOLID_FOREGROUND
public static final short SOLID_FOREGROUND
Solidly filled- See Also:
- Constant Field Values
-
FINE_DOTS
public static final short FINE_DOTS
Small fine dots- See Also:
- Constant Field Values
-
ALT_BARS
public static final short ALT_BARS
Wide dots- See Also:
- Constant Field Values
-
SPARSE_DOTS
public static final short SPARSE_DOTS
Sparse dots- See Also:
- Constant Field Values
-
THICK_HORZ_BANDS
public static final short THICK_HORZ_BANDS
Thick horizontal bands- See Also:
- Constant Field Values
-
THICK_VERT_BANDS
public static final short THICK_VERT_BANDS
Thick vertical bands- See Also:
- Constant Field Values
-
THICK_BACKWARD_DIAG
public static final short THICK_BACKWARD_DIAG
Thick backward facing diagonals- See Also:
- Constant Field Values
-
THICK_FORWARD_DIAG
public static final short THICK_FORWARD_DIAG
Thick forward facing diagonals- See Also:
- Constant Field Values
-
BIG_SPOTS
public static final short BIG_SPOTS
Large spots- See Also:
- Constant Field Values
-
BRICKS
public static final short BRICKS
Brick-like layout- See Also:
- Constant Field Values
-
THIN_HORZ_BANDS
public static final short THIN_HORZ_BANDS
Thin horizontal bands- See Also:
- Constant Field Values
-
THIN_VERT_BANDS
public static final short THIN_VERT_BANDS
Thin vertical bands- See Also:
- Constant Field Values
-
THIN_BACKWARD_DIAG
public static final short THIN_BACKWARD_DIAG
Thin backward diagonal- See Also:
- Constant Field Values
-
THIN_FORWARD_DIAG
public static final short THIN_FORWARD_DIAG
Thin forward diagonal- See Also:
- Constant Field Values
-
SQUARES
public static final short SQUARES
Squares- See Also:
- Constant Field Values
-
DIAMONDS
public static final short DIAMONDS
Diamonds- See Also:
- Constant Field Values
-
LESS_DOTS
public static final short LESS_DOTS
Less Dots- See Also:
- Constant Field Values
-
LEAST_DOTS
public static final short LEAST_DOTS
Least Dots- See Also:
- Constant Field Values
-
-
Constructor Detail
-
HSSFCellStyle
protected HSSFCellStyle(short index, ExtendedFormatRecord rec)
Creates new HSSFCellStyle why would you want to do this??
-
-
Method Detail
-
getIndex
public short getIndex()
get the index within the HSSFWorkbook (sequence within the collection of ExtnededFormat objects)- Returns:
- unique index number of the underlying record this style represents (probably you don't care unless you're comparing which one is which)
-
setDataFormat
public void setDataFormat(short fmt)
set the data format (must be a valid format)- See Also:
HSSFDataFormat
-
getDataFormat
public short getDataFormat()
get the index of the format- See Also:
HSSFDataFormat
-
getDataFormatString
public String getDataFormatString(Workbook workbook)
Get the contents of the format string, by looking up the DataFormat against the supplied workbook- See Also:
HSSFDataFormat
-
setFont
public void setFont(HSSFFont font)
set the font for this style- Parameters:
font
- a font object created or retreived from the HSSFWorkbook object- See Also:
HSSFWorkbook.createFont()
,HSSFWorkbook.getFontAt(short)
-
getFontIndex
public short getFontIndex()
-
setHidden
public void setHidden(boolean hidden)
set the cell's using this style to be hidden- Parameters:
hidden
- - whether the cell using this style should be hidden
-
getHidden
public boolean getHidden()
get whether the cell's using this style are to be hidden- Returns:
- hidden - whether the cell using this style should be hidden
-
setLocked
public void setLocked(boolean locked)
set the cell's using this style to be locked- Parameters:
locked
- - whether the cell using this style should be locked
-
getLocked
public boolean getLocked()
get whether the cell's using this style are to be locked- Returns:
- hidden - whether the cell using this style should be locked
-
setAlignment
public void setAlignment(short align)
set the type of horizontal alignment for the cell- Parameters:
align
- - the type of alignment- See Also:
ALIGN_GENERAL
,ALIGN_LEFT
,ALIGN_CENTER
,ALIGN_RIGHT
,ALIGN_FILL
,ALIGN_JUSTIFY
,ALIGN_CENTER_SELECTION
-
getAlignment
public short getAlignment()
get the type of horizontal alignment for the cell- Returns:
- align - the type of alignment
- See Also:
ALIGN_GENERAL
,ALIGN_LEFT
,ALIGN_CENTER
,ALIGN_RIGHT
,ALIGN_FILL
,ALIGN_JUSTIFY
,ALIGN_CENTER_SELECTION
-
setWrapText
public void setWrapText(boolean wrapped)
set whether the text should be wrapped- Parameters:
wrapped
- wrap text or not
-
getWrapText
public boolean getWrapText()
get whether the text should be wrapped- Returns:
- wrap text or not
-
setVerticalAlignment
public void setVerticalAlignment(short align)
set the type of vertical alignment for the cell- Parameters:
align
- the type of alignment- See Also:
VERTICAL_TOP
,VERTICAL_CENTER
,VERTICAL_BOTTOM
,VERTICAL_JUSTIFY
-
getVerticalAlignment
public short getVerticalAlignment()
get the type of vertical alignment for the cell- Returns:
- align the type of alignment
- See Also:
VERTICAL_TOP
,VERTICAL_CENTER
,VERTICAL_BOTTOM
,VERTICAL_JUSTIFY
-
setRotation
public void setRotation(short rotation)
set the degree of rotation for the text in the cell- Parameters:
rotation
- degrees (between -90 and 90 degrees)
-
getRotation
public short getRotation()
get the degree of rotation for the text in the cell- Returns:
- rotation degrees (between -90 and 90 degrees)
-
setIndention
public void setIndention(short indent)
set the number of spaces to indent the text in the cell- Parameters:
indent
- - number of spaces
-
getIndention
public short getIndention()
get the number of spaces to indent the text in the cell- Returns:
- indent - number of spaces
-
setBorderLeft
public void setBorderLeft(short border)
set the type of border to use for the left border of the cell- Parameters:
border
- type- See Also:
BORDER_NONE
,BORDER_THIN
,BORDER_MEDIUM
,BORDER_DASHED
,BORDER_DOTTED
,BORDER_THICK
,BORDER_DOUBLE
,BORDER_HAIR
,BORDER_MEDIUM_DASHED
,BORDER_DASH_DOT
,BORDER_MEDIUM_DASH_DOT
,BORDER_DASH_DOT_DOT
,BORDER_MEDIUM_DASH_DOT_DOT
,BORDER_SLANTED_DASH_DOT
-
getBorderLeft
public short getBorderLeft()
get the type of border to use for the left border of the cell- Returns:
- border type
- See Also:
BORDER_NONE
,BORDER_THIN
,BORDER_MEDIUM
,BORDER_DASHED
,BORDER_DOTTED
,BORDER_THICK
,BORDER_DOUBLE
,BORDER_HAIR
,BORDER_MEDIUM_DASHED
,BORDER_DASH_DOT
,BORDER_MEDIUM_DASH_DOT
,BORDER_DASH_DOT_DOT
,BORDER_MEDIUM_DASH_DOT_DOT
,BORDER_SLANTED_DASH_DOT
-
setBorderRight
public void setBorderRight(short border)
set the type of border to use for the right border of the cell- Parameters:
border
- type- See Also:
BORDER_NONE
,BORDER_THIN
,BORDER_MEDIUM
,BORDER_DASHED
,BORDER_DOTTED
,BORDER_THICK
,BORDER_DOUBLE
,BORDER_HAIR
,BORDER_MEDIUM_DASHED
,BORDER_DASH_DOT
,BORDER_MEDIUM_DASH_DOT
,BORDER_DASH_DOT_DOT
,BORDER_MEDIUM_DASH_DOT_DOT
,BORDER_SLANTED_DASH_DOT
-
getBorderRight
public short getBorderRight()
get the type of border to use for the right border of the cell- Returns:
- border type
- See Also:
BORDER_NONE
,BORDER_THIN
,BORDER_MEDIUM
,BORDER_DASHED
,BORDER_DOTTED
,BORDER_THICK
,BORDER_DOUBLE
,BORDER_HAIR
,BORDER_MEDIUM_DASHED
,BORDER_DASH_DOT
,BORDER_MEDIUM_DASH_DOT
,BORDER_DASH_DOT_DOT
,BORDER_MEDIUM_DASH_DOT_DOT
,BORDER_SLANTED_DASH_DOT
-
setBorderTop
public void setBorderTop(short border)
set the type of border to use for the top border of the cell- Parameters:
border
- type- See Also:
BORDER_NONE
,BORDER_THIN
,BORDER_MEDIUM
,BORDER_DASHED
,BORDER_DOTTED
,BORDER_THICK
,BORDER_DOUBLE
,BORDER_HAIR
,BORDER_MEDIUM_DASHED
,BORDER_DASH_DOT
,BORDER_MEDIUM_DASH_DOT
,BORDER_DASH_DOT_DOT
,BORDER_MEDIUM_DASH_DOT_DOT
,BORDER_SLANTED_DASH_DOT
-
getBorderTop
public short getBorderTop()
get the type of border to use for the top border of the cell- Returns:
- border type
- See Also:
BORDER_NONE
,BORDER_THIN
,BORDER_MEDIUM
,BORDER_DASHED
,BORDER_DOTTED
,BORDER_THICK
,BORDER_DOUBLE
,BORDER_HAIR
,BORDER_MEDIUM_DASHED
,BORDER_DASH_DOT
,BORDER_MEDIUM_DASH_DOT
,BORDER_DASH_DOT_DOT
,BORDER_MEDIUM_DASH_DOT_DOT
,BORDER_SLANTED_DASH_DOT
-
setBorderBottom
public void setBorderBottom(short border)
set the type of border to use for the bottom border of the cell- Parameters:
border
- type- See Also:
BORDER_NONE
,BORDER_THIN
,BORDER_MEDIUM
,BORDER_DASHED
,BORDER_DOTTED
,BORDER_THICK
,BORDER_DOUBLE
,BORDER_HAIR
,BORDER_MEDIUM_DASHED
,BORDER_DASH_DOT
,BORDER_MEDIUM_DASH_DOT
,BORDER_DASH_DOT_DOT
,BORDER_MEDIUM_DASH_DOT_DOT
,BORDER_SLANTED_DASH_DOT
-
getBorderBottom
public short getBorderBottom()
get the type of border to use for the bottom border of the cell- Returns:
- border type
- See Also:
BORDER_NONE
,BORDER_THIN
,BORDER_MEDIUM
,BORDER_DASHED
,BORDER_DOTTED
,BORDER_THICK
,BORDER_DOUBLE
,BORDER_HAIR
,BORDER_MEDIUM_DASHED
,BORDER_DASH_DOT
,BORDER_MEDIUM_DASH_DOT
,BORDER_DASH_DOT_DOT
,BORDER_MEDIUM_DASH_DOT_DOT
,BORDER_SLANTED_DASH_DOT
-
setLeftBorderColor
public void setLeftBorderColor(short color)
set the color to use for the left border- Parameters:
color
-
-
getLeftBorderColor
public short getLeftBorderColor()
get the color to use for the left border- Returns:
- color
-
setRightBorderColor
public void setRightBorderColor(short color)
set the color to use for the right border- Parameters:
color
-
-
getRightBorderColor
public short getRightBorderColor()
get the color to use for the left border- Returns:
- color
-
setTopBorderColor
public void setTopBorderColor(short color)
set the color to use for the top border- Parameters:
color
-
-
getTopBorderColor
public short getTopBorderColor()
get the color to use for the top border- Returns:
- color
-
setBottomBorderColor
public void setBottomBorderColor(short color)
set the color to use for the bottom border- Parameters:
color
-
-
getBottomBorderColor
public short getBottomBorderColor()
get the color to use for the left border- Returns:
- color
-
setFillPattern
public void setFillPattern(short fp)
setting to one fills the cell with the foreground color... No idea about other values- Parameters:
fp
- fill pattern (set to 1 to fill w/foreground color)- See Also:
NO_FILL
,SOLID_FOREGROUND
,FINE_DOTS
,ALT_BARS
,SPARSE_DOTS
,THICK_HORZ_BANDS
,THICK_VERT_BANDS
,THICK_BACKWARD_DIAG
,THICK_FORWARD_DIAG
,BIG_SPOTS
,BRICKS
,THIN_HORZ_BANDS
,THIN_VERT_BANDS
,THIN_BACKWARD_DIAG
,THIN_FORWARD_DIAG
,SQUARES
,DIAMONDS
-
getFillPattern
public short getFillPattern()
get the fill pattern (??) - set to 1 to fill with foreground color- Returns:
- fill pattern
-
setFillBackgroundColor
public void setFillBackgroundColor(short bg)
set the background fill color.For example:
cs.setFillPattern(HSSFCellStyle.FINE_DOTS ); cs.setFillBackgroundColor(new HSSFColor.RED().getIndex());
optionally a Foreground and background fill can be applied: Note: Ensure Foreground color is set prior to backgroundcs.setFillPattern(HSSFCellStyle.FINE_DOTS ); cs.setFillForegroundColor(new HSSFColor.BLUE().getIndex()); cs.setFillBackgroundColor(new HSSFColor.RED().getIndex());
or, for the special case of SOLID_FILL:cs.setFillPattern(HSSFCellStyle.SOLID_FOREGROUND ); cs.setFillForegroundColor(new HSSFColor.RED().getIndex());
It is necessary to set the fill style in order for the color to be shown in the cell.- Parameters:
bg
- color
-
getFillBackgroundColor
public short getFillBackgroundColor()
get the background fill color- Returns:
- fill color
-
setFillForegroundColor
public void setFillForegroundColor(short bg)
set the foreground fill color Note: Ensure Foreground color is set prior to background color.- Parameters:
bg
- color
-
getFillForegroundColor
public short getFillForegroundColor()
get the foreground fill color- Returns:
- fill color
-
-