Package loci.poi.hssf.usermodel
Class HSSFCellStyle
java.lang.Object
loci.poi.hssf.usermodel.HSSFCellStyle
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:
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final shortcenter horizontal alignmentstatic final shortcenter-selection? horizontal alignmentstatic final shortfill? horizontal alignmentstatic final shortgeneral (normal) horizontal alignmentstatic final shortjustified horizontal alignmentstatic final shortleft-justified horizontal alignmentstatic final shortright-justified horizontal alignmentstatic final shortWide dotsstatic final shortLarge spotsstatic final shortdash-dot borderstatic final shortdash-dot-dot borderstatic final shortdash borderstatic final shorthair-line borderstatic final shortdouble-line borderstatic final shortdot borderstatic final shortMedium borderstatic final shortmedium dash-dot borderstatic final shortmedium dash-dot-dot borderstatic final shortMedium dashed borderstatic final shortNo borderstatic final shortslanted dash-dot borderstatic final shortThick borderstatic final shortThin borderstatic final shortBrick-like layoutstatic final shortDiamondsstatic final shortSmall fine dotsstatic final shortLeast Dotsstatic final shortLess Dotsstatic final shortNo backgroundstatic final shortSolidly filledstatic final shortSparse dotsstatic final shortSquaresstatic final shortThick backward facing diagonalsstatic final shortThick forward facing diagonalsstatic final shortThick horizontal bandsstatic final shortThick vertical bandsstatic final shortThin backward diagonalstatic final shortThin forward diagonalstatic final shortThin horizontal bandsstatic final shortThin vertical bandsstatic final shortbottom-aligned vertical alignmentstatic final shortcenter-aligned vertical alignmentstatic final shortvertically justified vertical alignmentstatic final shorttop-aligned vertical alignment -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedHSSFCellStyle(short index, ExtendedFormatRecord rec) Creates new HSSFCellStyle why would you want to do this?? -
Method Summary
Modifier and TypeMethodDescriptionshortget the type of horizontal alignment for the cellshortget the type of border to use for the bottom border of the cellshortget the type of border to use for the left border of the cellshortget the type of border to use for the right border of the cellshortget the type of border to use for the top border of the cellshortget the color to use for the left bordershortget the index of the formatgetDataFormatString(Workbook workbook) Get the contents of the format string, by looking up the DataFormat against the supplied workbookshortget the background fill colorshortget the foreground fill colorshortget the fill pattern (??) - set to 1 to fill with foreground colorshortbooleanget whether the cell's using this style are to be hiddenshortget the number of spaces to indent the text in the cellshortgetIndex()get the index within the HSSFWorkbook (sequence within the collection of ExtnededFormat objects)shortget the color to use for the left borderbooleanget whether the cell's using this style are to be lockedshortget the color to use for the left bordershortget the degree of rotation for the text in the cellshortget the color to use for the top bordershortget the type of vertical alignment for the cellbooleanget whether the text should be wrappedvoidsetAlignment(short align) set the type of horizontal alignment for the cellvoidsetBorderBottom(short border) set the type of border to use for the bottom border of the cellvoidsetBorderLeft(short border) set the type of border to use for the left border of the cellvoidsetBorderRight(short border) set the type of border to use for the right border of the cellvoidsetBorderTop(short border) set the type of border to use for the top border of the cellvoidsetBottomBorderColor(short color) set the color to use for the bottom bordervoidsetDataFormat(short fmt) set the data format (must be a valid format)voidsetFillBackgroundColor(short bg) set the background fill color.voidsetFillForegroundColor(short bg) set the foreground fill color Note: Ensure Foreground color is set prior to background color.voidsetFillPattern(short fp) setting to one fills the cell with the foreground color...voidset the font for this stylevoidsetHidden(boolean hidden) set the cell's using this style to be hiddenvoidsetIndention(short indent) set the number of spaces to indent the text in the cellvoidsetLeftBorderColor(short color) set the color to use for the left bordervoidsetLocked(boolean locked) set the cell's using this style to be lockedvoidsetRightBorderColor(short color) set the color to use for the right bordervoidsetRotation(short rotation) set the degree of rotation for the text in the cellvoidsetTopBorderColor(short color) set the color to use for the top bordervoidsetVerticalAlignment(short align) set the type of vertical alignment for the cellvoidsetWrapText(boolean wrapped) set whether the text should be wrapped
-
Field Details
-
ALIGN_GENERAL
public static final short ALIGN_GENERALgeneral (normal) horizontal alignment- See Also:
-
ALIGN_LEFT
public static final short ALIGN_LEFTleft-justified horizontal alignment- See Also:
-
ALIGN_CENTER
public static final short ALIGN_CENTERcenter horizontal alignment- See Also:
-
ALIGN_RIGHT
public static final short ALIGN_RIGHTright-justified horizontal alignment- See Also:
-
ALIGN_FILL
public static final short ALIGN_FILLfill? horizontal alignment- See Also:
-
ALIGN_JUSTIFY
public static final short ALIGN_JUSTIFYjustified horizontal alignment- See Also:
-
ALIGN_CENTER_SELECTION
public static final short ALIGN_CENTER_SELECTIONcenter-selection? horizontal alignment- See Also:
-
VERTICAL_TOP
public static final short VERTICAL_TOPtop-aligned vertical alignment- See Also:
-
VERTICAL_CENTER
public static final short VERTICAL_CENTERcenter-aligned vertical alignment- See Also:
-
VERTICAL_BOTTOM
public static final short VERTICAL_BOTTOMbottom-aligned vertical alignment- See Also:
-
VERTICAL_JUSTIFY
public static final short VERTICAL_JUSTIFYvertically justified vertical alignment- See Also:
-
BORDER_NONE
public static final short BORDER_NONENo border- See Also:
-
BORDER_THIN
public static final short BORDER_THINThin border- See Also:
-
BORDER_MEDIUM
public static final short BORDER_MEDIUMMedium border- See Also:
-
BORDER_DASHED
public static final short BORDER_DASHEDdash border- See Also:
-
BORDER_HAIR
public static final short BORDER_HAIRdot border- See Also:
-
BORDER_THICK
public static final short BORDER_THICKThick border- See Also:
-
BORDER_DOUBLE
public static final short BORDER_DOUBLEdouble-line border- See Also:
-
BORDER_DOTTED
public static final short BORDER_DOTTEDhair-line border- See Also:
-
BORDER_MEDIUM_DASHED
public static final short BORDER_MEDIUM_DASHEDMedium dashed border- See Also:
-
BORDER_DASH_DOT
public static final short BORDER_DASH_DOTdash-dot border- See Also:
-
BORDER_MEDIUM_DASH_DOT
public static final short BORDER_MEDIUM_DASH_DOTmedium dash-dot border- See Also:
-
BORDER_DASH_DOT_DOT
public static final short BORDER_DASH_DOT_DOTdash-dot-dot border- See Also:
-
BORDER_MEDIUM_DASH_DOT_DOT
public static final short BORDER_MEDIUM_DASH_DOT_DOTmedium dash-dot-dot border- See Also:
-
BORDER_SLANTED_DASH_DOT
public static final short BORDER_SLANTED_DASH_DOTslanted dash-dot border- See Also:
-
NO_FILL
public static final short NO_FILLNo background- See Also:
-
SOLID_FOREGROUND
public static final short SOLID_FOREGROUNDSolidly filled- See Also:
-
FINE_DOTS
public static final short FINE_DOTSSmall fine dots- See Also:
-
ALT_BARS
public static final short ALT_BARSWide dots- See Also:
-
SPARSE_DOTS
public static final short SPARSE_DOTSSparse dots- See Also:
-
THICK_HORZ_BANDS
public static final short THICK_HORZ_BANDSThick horizontal bands- See Also:
-
THICK_VERT_BANDS
public static final short THICK_VERT_BANDSThick vertical bands- See Also:
-
THICK_BACKWARD_DIAG
public static final short THICK_BACKWARD_DIAGThick backward facing diagonals- See Also:
-
THICK_FORWARD_DIAG
public static final short THICK_FORWARD_DIAGThick forward facing diagonals- See Also:
-
BIG_SPOTS
public static final short BIG_SPOTSLarge spots- See Also:
-
BRICKS
public static final short BRICKSBrick-like layout- See Also:
-
THIN_HORZ_BANDS
public static final short THIN_HORZ_BANDSThin horizontal bands- See Also:
-
THIN_VERT_BANDS
public static final short THIN_VERT_BANDSThin vertical bands- See Also:
-
THIN_BACKWARD_DIAG
public static final short THIN_BACKWARD_DIAGThin backward diagonal- See Also:
-
THIN_FORWARD_DIAG
public static final short THIN_FORWARD_DIAGThin forward diagonal- See Also:
-
SQUARES
public static final short SQUARESSquares- See Also:
-
DIAMONDS
public static final short DIAMONDSDiamonds- See Also:
-
LESS_DOTS
public static final short LESS_DOTSLess Dots- See Also:
-
LEAST_DOTS
public static final short LEAST_DOTSLeast Dots- See Also:
-
-
Constructor Details
-
HSSFCellStyle
Creates new HSSFCellStyle why would you want to do this??
-
-
Method Details
-
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:
-
getDataFormat
public short getDataFormat()get the index of the format- See Also:
-
getDataFormatString
Get the contents of the format string, by looking up the DataFormat against the supplied workbook- See Also:
-
setFont
set the font for this style- Parameters:
font- a font object created or retreived from the HSSFWorkbook object- See Also:
-
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:
-
getAlignment
public short getAlignment()get the type of horizontal alignment for the cell- Returns:
- align - the type of alignment
- See Also:
-
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:
-
getVerticalAlignment
public short getVerticalAlignment()get the type of vertical alignment for the cell- Returns:
- align the type of alignment
- See Also:
-
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 -
getBorderLeft
public short getBorderLeft()get the type of border to use for the left border of the cell -
setBorderRight
public void setBorderRight(short border) set the type of border to use for the right border of the cell -
getBorderRight
public short getBorderRight()get the type of border to use for the right border of the cell -
setBorderTop
public void setBorderTop(short border) set the type of border to use for the top border of the cell -
getBorderTop
public short getBorderTop()get the type of border to use for the top border of the cell -
setBorderBottom
public void setBorderBottom(short border) set the type of border to use for the bottom border of the cell -
getBorderBottom
public short getBorderBottom()get the type of border to use for the bottom border of the cell -
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:
-
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
-