Fields Summary |
---|
private ExtendedFormatRecord | format |
private short | index |
public static final short | ALIGN_GENERALgeneral (normal) horizontal alignment |
public static final short | ALIGN_LEFTleft-justified horizontal alignment |
public static final short | ALIGN_CENTERcenter horizontal alignment |
public static final short | ALIGN_RIGHTright-justified horizontal alignment |
public static final short | ALIGN_FILLfill? horizontal alignment |
public static final short | ALIGN_JUSTIFYjustified horizontal alignment |
public static final short | ALIGN_CENTER_SELECTIONcenter-selection? horizontal alignment |
public static final short | VERTICAL_TOPtop-aligned vertical alignment |
public static final short | VERTICAL_CENTERcenter-aligned vertical alignment |
public static final short | VERTICAL_BOTTOMbottom-aligned vertical alignment |
public static final short | VERTICAL_JUSTIFYvertically justified vertical alignment |
public static final short | BORDER_NONENo border |
public static final short | BORDER_THINThin border |
public static final short | BORDER_MEDIUMMedium border |
public static final short | BORDER_DASHEDdash border |
public static final short | BORDER_HAIRdot border |
public static final short | BORDER_THICKThick border |
public static final short | BORDER_DOUBLEdouble-line border |
public static final short | BORDER_DOTTEDhair-line border |
public static final short | BORDER_MEDIUM_DASHEDMedium dashed border |
public static final short | BORDER_DASH_DOTdash-dot border |
public static final short | BORDER_MEDIUM_DASH_DOTmedium dash-dot border |
public static final short | BORDER_DASH_DOT_DOTdash-dot-dot border |
public static final short | BORDER_MEDIUM_DASH_DOT_DOTmedium dash-dot-dot border |
public static final short | BORDER_SLANTED_DASH_DOTslanted dash-dot border |
public static final short | NO_FILLNo background |
public static final short | SOLID_FOREGROUNDSolidly filled |
public static final short | FINE_DOTSSmall fine dots |
public static final short | ALT_BARSWide dots |
public static final short | SPARSE_DOTSSparse dots |
public static final short | THICK_HORZ_BANDSThick horizontal bands |
public static final short | THICK_VERT_BANDSThick vertical bands |
public static final short | THICK_BACKWARD_DIAGThick backward facing diagonals |
public static final short | THICK_FORWARD_DIAGThick forward facing diagonals |
public static final short | BIG_SPOTSLarge spots |
public static final short | BRICKSBrick-like layout |
public static final short | THIN_HORZ_BANDSThin horizontal bands |
public static final short | THIN_VERT_BANDSThin vertical bands |
public static final short | THIN_BACKWARD_DIAGThin backward diagonal |
public static final short | THIN_FORWARD_DIAGThin forward diagonal |
public static final short | SQUARESSquares |
public static final short | DIAMONDSDiamonds |
public static final short | LESS_DOTSLess Dots |
public static final short | LEAST_DOTSLeast Dots |
Methods Summary |
---|
private void | checkDefaultBackgroundFills()Checks if the background and foreground fills are set correctly when one
or the other is set to the default color.
Works like the logic table below:
BACKGROUND FOREGROUND
NONE AUTOMATIC
0x41 0x40
NONE RED/ANYTHING
0x40 0xSOMETHING
if (format.getFillForeground() == org.apache.poi.hssf.util.HSSFColor.AUTOMATIC.index) {
//JMH: Why +1, hell why not. I guess it made some sense to someone at the time. Doesnt
//to me now.... But experience has shown that when the fore is set to AUTOMATIC then the
//background needs to be incremented......
if (format.getFillBackground() != (org.apache.poi.hssf.util.HSSFColor.AUTOMATIC.index+1))
setFillBackgroundColor((short)(org.apache.poi.hssf.util.HSSFColor.AUTOMATIC.index+1));
} else if (format.getFillBackground() == org.apache.poi.hssf.util.HSSFColor.AUTOMATIC.index+1)
//Now if the forground changes to a non-AUTOMATIC color the background resets itself!!!
if (format.getFillForeground() != org.apache.poi.hssf.util.HSSFColor.AUTOMATIC.index)
setFillBackgroundColor(org.apache.poi.hssf.util.HSSFColor.AUTOMATIC.index);
|
public short | getAlignment()get the type of horizontal alignment for the cell
return format.getAlignment();
|
public short | getBorderBottom()get the type of border to use for the bottom border of the cell
return format.getBorderBottom();
|
public short | getBorderLeft()get the type of border to use for the left border of the cell
return format.getBorderLeft();
|
public short | getBorderRight()get the type of border to use for the right border of the cell
return format.getBorderRight();
|
public short | getBorderTop()get the type of border to use for the top border of the cell
return format.getBorderTop();
|
public short | getBottomBorderColor()get the color to use for the left border
return format.getBottomBorderPaletteIdx();
|
public short | getDataFormat()get the index of the format
return format.getFormatIndex();
|
public short | getFillBackgroundColor()get the background fill color
short result = format.getFillBackground();
//JMH: Do this ridiculous conversion, and let HSSFCellStyle
//internally migrate back and forth
if (result == (HSSFColor.AUTOMATIC.index+1))
return HSSFColor.AUTOMATIC.index;
else return result;
|
public short | getFillForegroundColor()get the foreground fill color
return format.getFillForeground();
|
public short | getFillPattern()get the fill pattern (??) - set to 1 to fill with foreground color
return format.getAdtlFillPattern();
|
public short | getFontIndex()
return format.getFontIndex();
|
public boolean | getHidden()get whether the cell's using this style are to be hidden
return format.isHidden();
|
public short | getIndention()get the number of spaces to indent the text in the cell
return format.getIndent();
|
public short | getIndex()get the index within the HSSFWorkbook (sequence within the collection of ExtnededFormat objects)
return index;
|
public short | getLeftBorderColor()get the color to use for the left border
return format.getLeftBorderPaletteIdx();
|
public boolean | getLocked()get whether the cell's using this style are to be locked
return format.isLocked();
|
public short | getRightBorderColor()get the color to use for the left border
return format.getRightBorderPaletteIdx();
|
public short | getRotation()get the degree of rotation for the text in the cell
short rotation = format.getRotation();
if (rotation > 90)
//This is actually the 4th quadrant
rotation = (short)(90-rotation);
return rotation;
|
public short | getTopBorderColor()get the color to use for the top border
return format.getTopBorderPaletteIdx();
|
public short | getVerticalAlignment()get the type of vertical alignment for the cell
return format.getVerticalAlignment();
|
public boolean | getWrapText()get whether the text should be wrapped
return format.getWrapText();
|
public void | setAlignment(short align)set the type of horizontal alignment for the cell
format.setIndentNotParentAlignment(true);
format.setAlignment(align);
|
public void | setBorderBottom(short border)set the type of border to use for the bottom border of the cell
format.setIndentNotParentBorder(true);
format.setBorderBottom(border);
|
public void | setBorderLeft(short border)set the type of border to use for the left border of the cell
format.setIndentNotParentBorder(true);
format.setBorderLeft(border);
|
public void | setBorderRight(short border)set the type of border to use for the right border of the cell
format.setIndentNotParentBorder(true);
format.setBorderRight(border);
|
public void | setBorderTop(short border)set the type of border to use for the top border of the cell
format.setIndentNotParentBorder(true);
format.setBorderTop(border);
|
public void | setBottomBorderColor(short color)set the color to use for the bottom border
format.setBottomBorderPaletteIdx(color);
|
public void | setDataFormat(short fmt)set the data format (must be a valid format)
format.setFormatIndex(fmt);
|
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 background
cs.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.
format.setFillBackground(bg);
checkDefaultBackgroundFills();
|
public void | setFillForegroundColor(short bg)set the foreground fill color
Note: Ensure Foreground color is set prior to background color.
format.setFillForeground(bg);
checkDefaultBackgroundFills();
|
public void | setFillPattern(short fp)setting to one fills the cell with the foreground color... No idea about
other values
format.setAdtlFillPattern(fp);
|
public void | setFont(org.apache.poi.hssf.usermodel.HSSFFont font)set the font for this style
format.setIndentNotParentFont(true);
short fontindex = font.getIndex();
format.setFontIndex(fontindex);
|
public void | setHidden(boolean hidden)set the cell's using this style to be hidden
format.setIndentNotParentCellOptions(true);
format.setHidden(hidden);
|
public void | setIndention(short indent)set the number of spaces to indent the text in the cell
format.setIndent(indent);
|
public void | setLeftBorderColor(short color)set the color to use for the left border
format.setLeftBorderPaletteIdx(color);
|
public void | setLocked(boolean locked)set the cell's using this style to be locked
format.setIndentNotParentCellOptions(true);
format.setLocked(locked);
|
public void | setRightBorderColor(short color)set the color to use for the right border
format.setRightBorderPaletteIdx(color);
|
public void | setRotation(short rotation)set the degree of rotation for the text in the cell
if ((rotation < 0)&&(rotation >= -90)) {
//Take care of the funny 4th quadrant issue
//The 4th quadrant (-1 to -90) is stored as (91 to 180)
rotation = (short)(90 - rotation);
}
else if ((rotation < -90) ||(rotation > 90))
//Do not allow an incorrect rotation to be set
throw new IllegalArgumentException("The rotation must be between -90 and 90 degrees");
format.setRotation(rotation);
|
public void | setTopBorderColor(short color)set the color to use for the top border
format.setTopBorderPaletteIdx(color);
|
public void | setVerticalAlignment(short align)set the type of vertical alignment for the cell
format.setVerticalAlignment(align);
|
public void | setWrapText(boolean wrapped)set whether the text should be wrapped
format.setIndentNotParentAlignment(true);
format.setWrapText(wrapped);
|