com.extentech.ExtenXLS
Class FormatHandle

java.lang.Object
  extended by com.extentech.ExtenXLS.FormatHandle
All Implemented Interfaces:
Handle, com.extentech.formats.XLS.FormatConstants

public class FormatHandle
extends Object
implements Handle, com.extentech.formats.XLS.FormatConstants

Provides methods for querying and changing cell formatting information. Cell formating includes fonts, borders, text alignment, background colors, cell protection (locking), etc.

The mutator methods of a FormatHandle object directly and immediately change the formatting of the cell(s) to which it is applied. Under no circumstances will a FormatHandle alter the formatting of cells to which it is not applied. The list of cells to which a FormatHandle applies may be queried with the getCells() method. Additional cells may be added with addCell(com.extentech.ExtenXLS.CellHandle) and related methods.

A FormatHandle may also be obtained for a row or a column. In such a case the FormatHandle sets the default formats for the row or column. The default format for a row or column is the format which appears when no other formats for the cell are specified, such as for newly created cells.

Author:
John McMahon

Field Summary
static short colorBACKGROUND
           
static short colorBORDER
           
static short colorFONT
          Convert a converted hex string to a color int String must include beginning "#" also handle color # 9 exception
static short colorFOREGROUND
           
static Map<String,String> currencyFormatMap
           
static Map<String,String> dateFormatMap
           
static Map<String,String> numericFormatMap
           
 
Fields inherited from interface com.extentech.formats.XLS.FormatConstants
ALIGN_CENTER, ALIGN_CENTER_ACROSS_SELECTION, ALIGN_DEFAULT, ALIGN_FILL, ALIGN_JUSTIFY, ALIGN_LEFT, ALIGN_RIGHT, ALIGN_VERTICAL_BOTTOM, ALIGN_VERTICAL_CENTER, ALIGN_VERTICAL_JUSTIFY, ALIGN_VERTICAL_TOP, Aqua, Black, Blue, BlueGray, BOLD, BORDER_DASH_DOT, BORDER_DASH_DOT_DOT, BORDER_DASHED, BORDER_DOTTED, BORDER_DOUBLE, BORDER_HAIR, BORDER_MEDIUM, BORDER_MEDIUM_DASH_DOT, BORDER_MEDIUM_DASH_DOT_DOT, BORDER_MEDIUM_DASHED, BORDER_NAMES, BORDER_NAMES_HTML, BORDER_NONE, BORDER_SIZES_HTML, BORDER_SLANTED_DASH_DOT, BORDER_THICK, BORDER_THIN, BrightGreen, Brown, BUILTIN_FORMATS, BUILTIN_FORMATS_JP, BUILTIN_FORMATS_MHTML, COLOR_AQUA, COLOR_BLACK, COLOR_BLACK2, COLOR_BLACK3, COLOR_BLUE, COLOR_BLUE_GRAY, COLOR_BRIGHT_GREEN, COLOR_BROWN, COLOR_DARK_BLUE, COLOR_DARK_GREEN, COLOR_DARK_PURPLE, COLOR_DARK_RED, COLOR_DARK_TEAL, COLOR_DARK_YELLOW, COLOR_GOLD, COLOR_GRAY25, COLOR_GRAY40, COLOR_GRAY50, COLOR_GRAY80, COLOR_GREEN, COLOR_INDIGO, COLOR_LAVENDER, COLOR_LIGHT_BLUE, COLOR_LIGHT_GREEN, COLOR_LIGHT_ORANGE, COLOR_LIGHT_PURPLE, COLOR_LIGHT_TURQUOISE, COLOR_LIGHT_YELLOW, COLOR_LIME, COLOR_MEDIUM_PURPLE, COLOR_OLIVE_GREEN, COLOR_ORANGE, COLOR_PALE_BLUE, COLOR_PINK, COLOR_PLUM, COLOR_RED, COLOR_ROSE, COLOR_SALMON, COLOR_SEA_GREEN, COLOR_SKY_BLUE, COLOR_TAN, COLOR_TEAL, COLOR_TURQUOISE, COLOR_VIOLET, COLOR_WHITE, COLOR_WHITE2, COLOR_WHITE3, COLOR_YELLOW, COLORNAMES, COLORTABLE, CURRENCY_FORMATS, Dark_Blue, Dark_Green, Dark_Purple, Dark_Red, Dark_Teal, Dark_Yellow, DATE_FORMATS, DEFAULT_FONT_FACE, DEFAULT_FONT_SIZE, DEFAULT_FONT_WEIGHT, EXCEL_FORMAT_LOOKUP, FORMAT_NOSCRIPT, FORMAT_SUBSCRIPT, FORMAT_SUPERSCRIPT, Gold, Gray15, Gray25, Gray40, Gray50, Gray80, Green, HORIZONTAL_ALIGNMENTS, HTMLCOLORNAMES, Indigo, Lavender, Light_Blue, Light_Green, Light_Orange, Light_Purple, Light_Turquoise, Light_Yellow, Lime, Medium_Purple, NUMERIC_FORMATS, OliveGreen, Orange, PaleBlue, PATTERN_CHECKERBOARD1, PATTERN_CHECKERBOARD2, PATTERN_CROSSPATCH1, PATTERN_DIAG_STRIPES1, PATTERN_DIAG_STRIPES2, PATTERN_DIAG_STRIPES3, PATTERN_DIAG_STRIPES4, PATTERN_DIAG_STRIPES5, PATTERN_DIAG_STRIPES6, PATTERN_DIAG_STRIPES7, PATTERN_DIAG_STRIPES8, PATTERN_FILLED, PATTERN_GRID1, PATTERN_HOR_STRIPES1, PATTERN_HOR_STRIPES2, PATTERN_HOR_STRIPES3, PATTERN_HOR_STRIPES4, PATTERN_HVY_DOTS, PATTERN_HVY_FILL, PATTERN_LIGHT_DOTS, PATTERN_LIGHT_FILL, PATTERN_MED_DOTS, PATTERN_MED_FILL, PATTERN_NONE, PATTERN_PATCHY1, PATTERN_PATCHY2, PATTERN_PATCHY3, PATTERN_PATCHY4, PATTERN_VERT_STRIPES1, PATTERN_VERT_STRIPES2, PATTERN_VERT_STRIPES3, PATTERN_VERT_STRIPES4, patternmap, Pink, PLAIN, Plum, Red, Rose, Salmon, SeaGreen, SkyBlue, STYLE_UNDERLINE_DOUBLE, STYLE_UNDERLINE_DOUBLE_ACCTG, STYLE_UNDERLINE_NONE, STYLE_UNDERLINE_SINGLE, STYLE_UNDERLINE_SINGLE_ACCTG, SVGCOLORSTRINGS, Tan, Teal, Turquoise, VERTICAL_ALIGNMENTS, Violet, White, Yellow
 
Constructor Summary
FormatHandle()
          Nullary constructor for use in bean context.
FormatHandle(CellHandle c)
          Creates a FormatHandle for the given cell.
FormatHandle(WorkBook book)
          Constructs a FormatHandle for the given WorkBook's default format.
FormatHandle(com.extentech.formats.XLS.WorkBook book, int xfnum)
          Constructs a FormatHandle for the given format ID and WorkBook.
FormatHandle(WorkBook workBook, int i)
          Jan 27, 2011
FormatHandle(WorkBook book, String fontname, int fontstyle, int fontsize)
           
FormatHandle(WorkBook book, com.extentech.formats.XLS.Xf xfr)
          Constructs a FormatHandle for the given WorkBook and format record.
 
Method Summary
 void addCell(CellHandle c)
          add a Cell to this FormatHandle thus applying the Format to the Cell
 void addCellArray(CellHandle[] crcells)
          Apply this Format to a Range of Cells
 void addCellRange(CellRange cr)
          Apply this Format to a Range of Cells
 void addCells(List cx)
          Add a List of Cells to this FormatHandle
static int addFont(com.extentech.formats.XLS.Font f, WorkBookHandle bk)
          adds a font to the global font store only if exact font is not already present
 int addXf(com.extentech.formats.XLS.Xf sourceXf)
          adds all formatting represented by the sourceXf to this workbook, if not already present
This is used internally for transferring formats from one workbook to another
static int BorderStringToInt(String s)
           
 Object clone()
          Create a copy of this FormatHandle with its own Xf
static com.extentech.formats.XLS.Xf cloneXf(com.extentech.formats.XLS.Xf xf, com.extentech.formats.XLS.Font f, com.extentech.formats.XLS.WorkBook wkbook)
          static version of cloneXf
static com.extentech.formats.XLS.Xf cloneXf(com.extentech.formats.XLS.Xf xf, com.extentech.formats.XLS.WorkBook wkbook)
          static version of cloneXf
static String colorToHexString(Color c)
          Convert a java.awt.Color to a hex string.
 String convertFormatString(String pattern)
          converts an Excel-style format string to a Java Format string.
 boolean equals(Object another)
          overrides the equals method to perform equality based on format properties ------------------------------------------------------------
 int[] getAllBorderColors()
          return the 5 border line colors (l, r, t, b, diag)
 int[] getAllBorderLineStyles()
          return the 5 border lines styles (l, r, t, b, diag)
 int getBackgroundColor()
          get the Pattern Background Color for this Format Pattern
 boolean getBold()
          Get if the font is bold
 Color getBorderBottomColor()
          Get the Right border color
 Color[] getBorderColors()
          returns Border Colors of Cell ie: top, left, bottom, right returns null or 1 color for each of 4 sides 1,1,1,1 represents a border all around the cell 1,1,0,0 represents on the top left edge of the cell
 Color getBorderLeftColor()
          Get the Left border color
 Color getBorderRightColor()
          Get the Right border color
 Color getBorderTopColor()
          Get the Top border color
 int getBottomBorderLineStyle()
          Get the border line style
 int getCellBackgroundColor()
          get the Pattern Background Color for this Formatted Cell This method handles display of conditional formats for the cell checks for conditional format, then applies it if conditions are true.
 int getCellRotation()
          Get the rotation of the cell.
 List getCells()
          Get the List of Cells for this FormatHandle
static Color getColor(int col)
          returns the index of the Color within the Colortable
static int getColorInt(Color col)
          returns the index of the Color within the Colortable
 int getFillPattern()
          get the fill pattern for this format
 com.extentech.formats.XLS.Font getFont()
          returns the existing font record for this Format Font is an internal record and should not be accessed by end users
 Color getFontColor()
          Get the Font foreground (text) color
 int getFontHeight()
          Returns the Font's height in 1/20th point increment
 double getFontHeightInPoints()
          Get the font height in points
 String getFontName()
          Returns the Font's name
 int getFontWeight()
          Get the font weight
 int getForegroundColor()
          get the Background Color for this Format NOTE: Foreground color = the CELL BACKGROUND color color for all patterns and Background color= the PATTERN color for all patterns != Solid For PATTERN_SOLID, Foreground color=CELL BACKGROUND color and Background Color=64 (white).
 int getFormatId()
          The format ID allows setting of the format for a Cell without adding it to the Format's Cell Collection.
 String getFormatPattern()
          Gets the number format pattern for this format, if set.
 int getFormatPatternId()
          Gets the Excel format ID for this format's number format pattern.
 int getHorizontalAlignment()
          Returns an int representing the current horizontal alignment in this FormatHandle.
 int getIndent()
          return indent (1 = 3 spaces)
 boolean getIsBold()
          Get if this format is bold or not
 boolean getItalic()
          Get if the font is italic
 String getJavaFormatString()
          provides a mapping between Excel formats and Java formats
see: http://java.sun.com/docs/books/tutorial/i18n/format/decimalFormat.html
 String getJSON(int XFNum)
          Get a JSON representation of the format
 org.json.JSONObject getJSONObject(int XFNum)
          Get a JSON representation of the format font height is represented as HTML pt size
 int getLeftBorderLineStyle()
          Get the border line style
 int getRightBorderLineStyle()
          Get the border line style
 boolean getStricken()
          Determine if the format handle refers to a font stricken out
 int getTopBorderLineStyle()
          Get the border line style
 int getTrueForegroundColor()
          returns the foreground color setting regardless of format pattern (which can switch fg and bg)
 boolean getUnderlined()
          Get if the font is underlined
 int getUnderlineStyle()
          Return an int representing the underline style These map to the STYLE_UNDERLINE static integers *
 int getVerticalAlignment()
          Returns an int representing the current Vertical alignment in this FormatHandle.
 com.extentech.formats.XLS.WorkBook getWorkBook()
           
 boolean getWrapText()
          Get the cell wrapping behavior for this FormatHandle.
 String getXML(int XFNum)
          Returns an XML fragment representing the FormatHandle
static Color HexStringToColor(String s)
          convert hex string RGB to a Color
static int HexStringToColorInt(String s, short colorType)
          convert hex string RGB to Excel colortable int format
 boolean isCurrency()
          returns whether this Format is formatted as a Currency
 boolean isDate()
          returns whether this Format is formatted as a Date
 boolean isFormulaHidden()
          returns whether this FormatHandle is set to hide formula strings
 boolean isLocked()
          returns whether this Format Handle specifies that cells are locked for changing
 boolean isRedWhenNegative()
          Returns true if the value should be red due to a combination of a format pattern and a negative number
 boolean isStyleXf()
          return truth of "this Xf rec is a style xf"
 FormatHandle pack()
          Deprecated.  
 void setBackgroundColor(Color colr)
          set the Background Color for this Format NOTE: Foreground color = the CELL BACKGROUND color color for all patterns and Background color= the PATTERN color for all patterns != Solid For PATTERN_SOLID, Foreground color=CELL BACKGROUND color and Background Color=64 (white).
 void setBackgroundColor(int t)
          set the background color for this Format NOTE: Foreground color = the CELL BACKGROUND color color for all patterns and Background color= the PATTERN color for all patterns != Solid For PATTERN_SOLID, Foreground color=CELL BACKGROUND color and Background Color=64 (white).
 void setBackgroundPattern(int t)
          set the Background Pattern for this Format
 void setBold(boolean isBold)
          Set the format handle to use standard bold text
 void setBorderBottomColor(Color x)
          Set the top border color
 void setBorderBottomColor(int x)
          Set the top border color
 void setBorderColor(Color col)
          set the border color for all borders (top, left, bottom, and right) to one java.awt.Color
 void setBorderColor(int x)
          set the border color for all borders (top, left, bottom, and right) to one color via color constant
 void setBorderColors(Color[] bordercolors)
          sets the border color for all borders (top, left, bottom and right) from a Color array
 void setBorderColors(int[] bordercolors)
          sets the border color for all borders (top, left, bottom and right) from an int array containing color constants
 void setBorderDiagonal(int x)
          Set the border line style
 void setBorderLeftColor(Color x)
          Set the top border color
 void setBorderLeftColor(int x)
          Set the top border color
 void setBorderLineStyle(int x)
          Sets the border line style using static BORDER_ shorts within FormatHandle
 void setBorderLineStyle(int[] b)
          set border line styles via array of ints representing border styles order= left, right, top, bottom, [diagonal]
 void setBorderLineStyle(short x)
          Set the border line style
 void setBorderRightColor(Color x)
          Set the top border color
 void setBorderRightColor(int x)
          Set the top border color
 void setBorderTopColor(Color x)
          Set the top border color
 void setBorderTopColor(int x)
          Set the top border color
 void setBottomBorderLineStyle(int x)
          Set the border line style
 void setCellBackgroundColor(Color colr)
          set the Cell Background Color for this Format NOTE: Foreground color = the CELL BACKGROUND color color for all patterns and Background color= the PATTERN color for all patterns != Solid For PATTERN_SOLID, Foreground color=CELL BACKGROUND color and Background Color=64 (white).
 void setCellBackgroundColor(int t)
          makes the cell a solid pattern background if no pattern was already present NOTE: Foreground color = the CELL BACKGROUND color color for all patterns and Background color= the PATTERN color for all patterns != Solid For PATTERN_SOLID, Foreground color=CELL BACKGROUND color and Background Color=64 (white).
 void setCellRotation(int align)
          Set the rotation of the cell in degrees.
 void setColHandle(ColHandle c)
          Set a column handle on this format handle, so all changes applied to this format will be applied to the entire column
 void setFont(com.extentech.formats.XLS.Font f)
          Set the Font for this Format.
 void setFont(String fn, int stl, double sz)
           
 void setFontColor(Color colr)
          set the Font Color for this Format
 void setFontColor(int t)
          set the Font Color for this Format
 void setFontHeight(int fontHeight)
          Set the Font's height in 1/20th point increment
 void setFontName(String fontName)
          Set the Font's name To be valid, this font name must be available on the client system.
 void setFontWeight(int wt)
          Set the font weight
 void setForegroundColor(Color colr)
          set the foreground Color for this Format NOTE: Foreground color = the CELL BACKGROUND color color for all patterns and Background color= the PATTERN color for all patterns != Solid For PATTERN_SOLID, Foreground color=CELL BACKGROUND color and Background Color=64 (white).
 void setForegroundColor(int t)
          set the Foreground Color for this Format NOTE: Foreground color = the CELL BACKGROUND color color for all patterns and Background color= the PATTERN color for all patterns != Solid For PATTERN_SOLID, Foreground color=CELL BACKGROUND color and Background Color=64 (white).
 void setFormatId(int x)
          set the pointer to the XFE or Conditional format
 void setFormatPattern(String pat)
          Sets the number format pattern for this format.
 void setFormatPatternId(int fmt)
          Sets the number format pattern based on the format ID number.
 void setFormulaHidden(boolean b)
          sets the cell attached to this FormatHandle to hide or show formula strings;
 void setHorizontalAlignment(int align)
          Set the horizontal alignment for this FormatHandle
 void setIndent(int indent)
          set indent (1= 3 spaces)
 void setItalic(boolean isItalic)
          Set if the font is italic
 void setLeftBorderLineStyle(int x)
          Set the border line style
 void setLocked(boolean locked)
          Locks the cell attached to this FormatHandle for editing (makes read-only) lock cell and make read-only
 void setPattern(int pat)
           
 void setRightBorderLineStyle(int x)
          Set the border line style
 void setRowHandle(RowHandle c)
          Set a row handle on this format handle, so all changes applied to this format will be applied to the entire row
 void setScript(int ss)
          super/sub (0 = none, 1 = super, 2 = sub)
 void setStricken(boolean isStricken)
          Set if the format handle is stricken out
 void setTopBorderLineStyle(int x)
          Set the border line style
 void setUnderlined(boolean isUnderlined)
          Set underline attribute on the font
 void setUnderlineStyle(int u)
          set the underline style for this font
 void setVerticalAlignment(int align)
          Set the Vertical alignment for this FormatHandle
 void setWorkBook(com.extentech.formats.XLS.WorkBook bk)
          Set the workbook for this FormatHandle
 void setWrapText(boolean wrapit)
          Set the cell wrapping behavior for this FormatHandle.
 void setXf(com.extentech.formats.XLS.Xf xrec)
          Sets the internal format to the FormatHandle.
 void stamp(CellHandle cell)
          Applies the format to a cell without establishing a relationship.
 void stamp(CellRange range)
          Applies the format to a cell range without establishing a relationship.
 String toString()
           
 
Methods inherited from class java.lang.Object
getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

numericFormatMap

public static final Map<String,String> numericFormatMap

currencyFormatMap

public static final Map<String,String> currencyFormatMap

dateFormatMap

public static final Map<String,String> dateFormatMap

colorFONT

public static short colorFONT
Convert a converted hex string to a color int String must include beginning "#" also handle color # 9 exception


colorBACKGROUND

public static short colorBACKGROUND

colorFOREGROUND

public static short colorFOREGROUND

colorBORDER

public static short colorBORDER
Constructor Detail

FormatHandle

public FormatHandle()
Nullary constructor for use in bean context. This is not part of the public API and should not be called.


FormatHandle

public FormatHandle(WorkBook book,
                    com.extentech.formats.XLS.Xf xfr)
Constructs a FormatHandle for the given WorkBook and format record. This is not part of the public API and should not be called.


FormatHandle

public FormatHandle(WorkBook book)
Constructs a FormatHandle for the given WorkBook's default format.


FormatHandle

public FormatHandle(com.extentech.formats.XLS.WorkBook book,
                    int xfnum)
Constructs a FormatHandle for the given format ID and WorkBook. This is useful for creating a FormatHandle with the same parameters as a cell that does not refer to the cell. For example:
 CellHandle cell = <get cell here>;
 FormatHandle format = new FormatHandle(
         cell.getWorkBook(), cell.getFormatId() );
 

Parameters:
book - the WorkBook from which the format should be retrieved
xfnum - the ID of the format

FormatHandle

public FormatHandle(CellHandle c)
Creates a FormatHandle for the given cell. This is not part of the public API and should not be called. Customers should use CellHandle.getFormatHandle() instead.


FormatHandle

public FormatHandle(WorkBook book,
                    String fontname,
                    int fontstyle,
                    int fontsize)

FormatHandle

public FormatHandle(WorkBook workBook,
                    int i)
Jan 27, 2011

Parameters:
workBook -
i -
Method Detail

equals

public boolean equals(Object another)
overrides the equals method to perform equality based on format properties ------------------------------------------------------------

Overrides:
equals in class Object
Parameters:
Object - another - the FormatHandle to compare with this FormatHandle
Returns:
true if this FormatHandle equals another

setLocked

public void setLocked(boolean locked)
Locks the cell attached to this FormatHandle for editing (makes read-only) lock cell and make read-only

Parameters:
boolean - locked - true if cells should be locked for this FormatHandle

setFormulaHidden

public void setFormulaHidden(boolean b)
sets the cell attached to this FormatHandle to hide or show formula strings;

Parameters:
boolean - b- true if formulas should be hidden for this FormatHandle

isFormulaHidden

public boolean isFormulaHidden()
returns whether this FormatHandle is set to hide formula strings

Returns:
true if the formula strings are hidden, false otherwise

isLocked

public boolean isLocked()
returns whether this Format Handle specifies that cells are locked for changing

Returns:
true if cells are locked

getJavaFormatString

public String getJavaFormatString()
provides a mapping between Excel formats and Java formats
see: http://java.sun.com/docs/books/tutorial/i18n/format/decimalFormat.html

Note there are slight Excel-specific differences in the format strings returned. Several numeric and currency formats in excel have different formatting for postive and negative numbers. In these cases, the java format string is split by semicolons and may contain text [Red] which is to specify the negative number should be displayed in red. Remove this from the string before passing into the Format class;

        G  Era designator  Text  AD  
        y  Year  Year  1996; 96  
        M  Month in year  Month  July; Jul; 07  
        w  Week in year  Number  27  
        W  Week in month  Number  2  
        D  Day in year  Number  189  
        d  Day in month  Number  10  
        F  Day of week in month  Number  2  
        E  Day in week  Text  Tuesday; Tue  
        a  Am/pm marker  Text  PM  
        H  Hour in day (0-23)  Number  0  
        k  Hour in day (1-24)  Number  24  
        K  Hour in am/pm (0-11)  Number  0  
        h  Hour in am/pm (1-12)  Number  12  
        m  Minute in hour  Number  30  
        s  Second in minute  Number  55  
        S  Millisecond  Number  978  
        z  Time zone  General time zone  Pacific Standard Time; PST; GMT-08:00  
        Z  Time zone  RFC 822 time zone  -0800

Returns:
String the formatting pattern for the cell

convertFormatString

public String convertFormatString(String pattern)
converts an Excel-style format string to a Java Format string.

Parameters:
String - pattern - Excel Format String
Returns:
String that can be used with the Java Format classes.
See Also:
getJavaFormatString

setBorderColors

public void setBorderColors(Color[] bordercolors)
sets the border color for all borders (top, left, bottom and right) from a Color array

NOTE: this setting will affect every cell which refers to this FormatHandle

Parameters:
java.awt.Color - array - 4-element array of desired border colors [T, L, B, R]

setBorderColors

public void setBorderColors(int[] bordercolors)
sets the border color for all borders (top, left, bottom and right) from an int array containing color constants

NOTE: this setting will affect every cell which refers to this FormatHandle

Parameters:
int[] - bordercolors - 4-element array of desired border color constants [T, L, B, R]
See Also:
constants

setBorderColor

public void setBorderColor(int x)
set the border color for all borders (top, left, bottom, and right) to one color via color constant

NOTE: this setting will affect every cell which refers to this FormatHandle

Parameters:
int - x - color constant which represents the color to set all border sides
See Also:
constants

setBorderColor

public void setBorderColor(Color col)
set the border color for all borders (top, left, bottom, and right) to one java.awt.Color

NOTE: this setting will affect every cell which refers to this FormatHandle

Parameters:
Color - col - color to set all border sides

setBorderRightColor

public void setBorderRightColor(int x)
Set the top border color

Parameters:
color - constant

setBorderRightColor

public void setBorderRightColor(Color x)
Set the top border color

Parameters:
color - constant

getBorderRightColor

public Color getBorderRightColor()
Get the Right border color

Returns:
color constant

setBorderLeftColor

public void setBorderLeftColor(int x)
Set the top border color

Parameters:
color - constant

setBorderLeftColor

public void setBorderLeftColor(Color x)
Set the top border color

Parameters:
color - constant

getBorderColors

public Color[] getBorderColors()
returns Border Colors of Cell ie: top, left, bottom, right returns null or 1 color for each of 4 sides 1,1,1,1 represents a border all around the cell 1,1,0,0 represents on the top left edge of the cell

Returns:
int array representing Cell borders

getBorderLeftColor

public Color getBorderLeftColor()
Get the Left border color

Returns:
color constant

setBorderTopColor

public void setBorderTopColor(int x)
Set the top border color

Parameters:
color - constant

getBorderTopColor

public Color getBorderTopColor()
Get the Top border color

Returns:
color constant

setBorderTopColor

public void setBorderTopColor(Color x)
Set the top border color

Parameters:
color - constant

setBorderBottomColor

public void setBorderBottomColor(int x)
Set the top border color

Parameters:
color - constant

setBorderBottomColor

public void setBorderBottomColor(Color x)
Set the top border color

Parameters:
color - constant

isRedWhenNegative

public boolean isRedWhenNegative()
Returns true if the value should be red due to a combination of a format pattern and a negative number

Returns:

getBorderBottomColor

public Color getBorderBottomColor()
Get the Right border color

Returns:
color constant

setTopBorderLineStyle

public void setTopBorderLineStyle(int x)
Set the border line style

Parameters:
line - style constant

getTopBorderLineStyle

public int getTopBorderLineStyle()
Get the border line style

Returns:
line style constant

setBottomBorderLineStyle

public void setBottomBorderLineStyle(int x)
Set the border line style

Parameters:
line - style constant

getBottomBorderLineStyle

public int getBottomBorderLineStyle()
Get the border line style

Returns:
line style constant

setLeftBorderLineStyle

public void setLeftBorderLineStyle(int x)
Set the border line style

Parameters:
line - style constant

getLeftBorderLineStyle

public int getLeftBorderLineStyle()
Get the border line style

Returns:
line style constant

setRightBorderLineStyle

public void setRightBorderLineStyle(int x)
Set the border line style

Parameters:
line - style constant

getRightBorderLineStyle

public int getRightBorderLineStyle()
Get the border line style

Returns:
line style constant

setBorderLineStyle

public void setBorderLineStyle(int x)
Sets the border line style using static BORDER_ shorts within FormatHandle

Parameters:
line - style constant

setBorderLineStyle

public void setBorderLineStyle(int[] b)
set border line styles via array of ints representing border styles order= left, right, top, bottom, [diagonal]

Parameters:
b - int[]

setBorderLineStyle

public void setBorderLineStyle(short x)
Set the border line style

Parameters:
line - style constant

getAllBorderLineStyles

public int[] getAllBorderLineStyles()
return the 5 border lines styles (l, r, t, b, diag)

Returns:

getAllBorderColors

public int[] getAllBorderColors()
return the 5 border line colors (l, r, t, b, diag)

Returns:

setBorderDiagonal

public void setBorderDiagonal(int x)
Set the border line style

Parameters:
line - style constant

setColHandle

public void setColHandle(ColHandle c)
Set a column handle on this format handle, so all changes applied to this format will be applied to the entire column

Parameters:
c -

setRowHandle

public void setRowHandle(RowHandle c)
Set a row handle on this format handle, so all changes applied to this format will be applied to the entire row

Parameters:
c -

clone

public Object clone()
Create a copy of this FormatHandle with its own Xf

Overrides:
clone in class Object
Returns:
the copied FormatHandle

toString

public String toString()
Overrides:
toString in class Object

setFontWeight

public void setFontWeight(int wt)
Set the font weight

Parameters:
wt -

getFontWeight

public int getFontWeight()
Get the font weight

Returns:

setFont

public void setFont(com.extentech.formats.XLS.Font f)
Set the Font for this Format. As adding a new Font and format increases the file size, try using this once for each distinct font used in the file, then use 'setFormatId' to share this font with other Cells. Roughly matches the functionality of the java.awt.Font class. Currently the style parameter is only useful for bold/normal weights. Italics, underlines, etc must be modified elsewhere. Note that in order to maintain java.awt.Font compatibility for bold/normal styles, defaults for weight/style have been mapped to 0 = normal (excel 200 weight) and 1 = bold (excel 700 weight)

Parameters:
String - font name
int - font style
int - font size

setFont

public void setFont(String fn,
                    int stl,
                    double sz)

addFont

public static int addFont(com.extentech.formats.XLS.Font f,
                          WorkBookHandle bk)
adds a font to the global font store only if exact font is not already present

Parameters:
f - Font
bk - WorkBookHandle

addCellRange

public void addCellRange(CellRange cr)
Apply this Format to a Range of Cells

Parameters:
CellRange - to apply the format to

addCellArray

public void addCellArray(CellHandle[] crcells)
Apply this Format to a Range of Cells

Parameters:
CellHandle - array to apply the format to

addCell

public void addCell(CellHandle c)
add a Cell to this FormatHandle thus applying the Format to the Cell

Parameters:
CellHandle - to apply the format to

addCells

public void addCells(List cx)
Add a List of Cells to this FormatHandle

Parameters:
cx -

getCells

public List getCells()
Get the List of Cells for this FormatHandle

Returns:

stamp

public void stamp(CellHandle cell)
Applies the format to a cell without establishing a relationship. The format represented by this FormatHandle will be applied to the cell but it will not be updated with any future changes. If you want that behavior use addCell instead.


stamp

public void stamp(CellRange range)
Applies the format to a cell range without establishing a relationship. The format represented by this FormatHandle will be applied to the cells but they will not be updated with any future changes. If you want that behavior use addCell instead.


setBackgroundPattern

public void setBackgroundPattern(int t)
set the Background Pattern for this Format

Parameters:
int - Excel color constant

isDate

public boolean isDate()
returns whether this Format is formatted as a Date

Returns:
boolean true if this Format is formatted as a Date

isCurrency

public boolean isCurrency()
returns whether this Format is formatted as a Currency

Returns:
boolean true if this Format is formatted as a currency

setUnderlineStyle

public void setUnderlineStyle(int u)
set the underline style for this font

Parameters:
int - u underline style one of the Font.STYLE_UNDERLINE constants

setScript

public void setScript(int ss)
super/sub (0 = none, 1 = super, 2 = sub)

Parameters:
int - script type for Format Font

setFontColor

public void setFontColor(int t)
set the Font Color for this Format

Parameters:
int - Excel color constant

setFontColor

public void setFontColor(Color colr)
set the Font Color for this Format

Parameters:
AWT - Color color constant

setForegroundColor

public void setForegroundColor(int t)
set the Foreground Color for this Format NOTE: Foreground color = the CELL BACKGROUND color color for all patterns and Background color= the PATTERN color for all patterns != Solid For PATTERN_SOLID, Foreground color=CELL BACKGROUND color and Background Color=64 (white).

Parameters:
int - Excel color constant

setForegroundColor

public void setForegroundColor(Color colr)
set the foreground Color for this Format NOTE: Foreground color = the CELL BACKGROUND color color for all patterns and Background color= the PATTERN color for all patterns != Solid For PATTERN_SOLID, Foreground color=CELL BACKGROUND color and Background Color=64 (white).

Parameters:
AWT - Color constant

setBackgroundColor

public void setBackgroundColor(int t)
set the background color for this Format NOTE: Foreground color = the CELL BACKGROUND color color for all patterns and Background color= the PATTERN color for all patterns != Solid For PATTERN_SOLID, Foreground color=CELL BACKGROUND color and Background Color=64 (white).

Parameters:
int - Excel color constant

setCellBackgroundColor

public void setCellBackgroundColor(Color colr)
set the Cell Background Color for this Format NOTE: Foreground color = the CELL BACKGROUND color color for all patterns and Background color= the PATTERN color for all patterns != Solid For PATTERN_SOLID, Foreground color=CELL BACKGROUND color and Background Color=64 (white).

Parameters:
awt - Color color constant

setCellBackgroundColor

public void setCellBackgroundColor(int t)
makes the cell a solid pattern background if no pattern was already present NOTE: Foreground color = the CELL BACKGROUND color color for all patterns and Background color= the PATTERN color for all patterns != Solid For PATTERN_SOLID, Foreground color=CELL BACKGROUND color and Background Color=64 (white).

Parameters:
int - Excel color constant

getBackgroundColor

public int getBackgroundColor()
get the Pattern Background Color for this Format Pattern

Returns:
the Excel color constant

getTrueForegroundColor

public int getTrueForegroundColor()
returns the foreground color setting regardless of format pattern (which can switch fg and bg)

Returns:

getCellBackgroundColor

public int getCellBackgroundColor()
get the Pattern Background Color for this Formatted Cell This method handles display of conditional formats for the cell checks for conditional format, then applies it if conditions are true.

Returns:
the Excel color constant

getForegroundColor

public int getForegroundColor()
get the Background Color for this Format NOTE: Foreground color = the CELL BACKGROUND color color for all patterns and Background color= the PATTERN color for all patterns != Solid For PATTERN_SOLID, Foreground color=CELL BACKGROUND color and Background Color=64 (white).

Returns:
the Excel color constant

setBackgroundColor

public void setBackgroundColor(Color colr)
set the Background Color for this Format NOTE: Foreground color = the CELL BACKGROUND color color for all patterns and Background color= the PATTERN color for all patterns != Solid For PATTERN_SOLID, Foreground color=CELL BACKGROUND color and Background Color=64 (white).

Parameters:
awt - Color color constant

setBold

public void setBold(boolean isBold)
Set the format handle to use standard bold text

Parameters:
boolean - isBold

getIsBold

public boolean getIsBold()
Get if this format is bold or not

Returns:
boolean whether the cell font format is bold

getUnderlineStyle

public int getUnderlineStyle()
Return an int representing the underline style These map to the STYLE_UNDERLINE static integers *

Returns:
int underline style

getFontHeightInPoints

public double getFontHeightInPoints()
Get the font height in points

Returns:
font height

getFontHeight

public int getFontHeight()
Returns the Font's height in 1/20th point increment

Returns:
font height

setFontHeight

public void setFontHeight(int fontHeight)
Set the Font's height in 1/20th point increment

Parameters:
new - font height

getFontName

public String getFontName()
Returns the Font's name

Returns:
font name

setFontName

public void setFontName(String fontName)
Set the Font's name To be valid, this font name must be available on the client system.

Parameters:
font - name

getStricken

public boolean getStricken()
Determine if the format handle refers to a font stricken out

Returns:
boolean representing if the FormatHandle is striking out a cell.

setStricken

public void setStricken(boolean isStricken)
Set if the format handle is stricken out

Parameters:
isStricken - boolean representing if the formatted cell should be stricken out.

getItalic

public boolean getItalic()
Get if the font is italic

Returns:
boolean representing if the formatted cell is italic.

setItalic

public void setItalic(boolean isItalic)
Set if the font is italic

Parameters:
isItalic - boolean representing if the formatted cell should be italic.

getUnderlined

public boolean getUnderlined()
Get if the font is underlined

Returns:
boolean representing if the formatted cell is underlined.

setUnderlined

public void setUnderlined(boolean isUnderlined)
Set underline attribute on the font

Parameters:
isUnderlined - boolean representing if the formatted cell should be underlined

getBold

public boolean getBold()
Get if the font is bold

Returns:
boolean representing if the formatted cell is bold

getFont

public com.extentech.formats.XLS.Font getFont()
returns the existing font record for this Format Font is an internal record and should not be accessed by end users

Returns:
the XLS Font record associated with this Format

setFormatPattern

public void setFormatPattern(String pat)
Sets the number format pattern for this format. All Excel built-in number formats are supported. Custom formats will not be applied by ExtenXLS (e.g. CellHandle.getFormattedStringVal()) but they will be written correctly to the output file. For more information on number format patterns see Microsoft KB264372.

Parameters:
pat - the Excel number format pattern to apply
See Also:
FormatConstantsImpl.getBuiltinFormats()

setPattern

public void setPattern(int pat)

getFormatId

public int getFormatId()
The format ID allows setting of the format for a Cell without adding it to the Format's Cell Collection. Use to decrease memory requirements when dealing with large collections of cells. Usage: mycell.setFormatId(myformat.getFormatId());

Returns:
the format ID for this Format

getFormatPattern

public String getFormatPattern()
Gets the number format pattern for this format, if set. For more information on number format patterns see Microsoft KB264372.

Returns:
the Excel number format pattern for this cell or null if none is applied

getFillPattern

public int getFillPattern()
get the fill pattern for this format


getColor

public static Color getColor(int col)
returns the index of the Color within the Colortable

Parameters:
the - index of the color in the colortable
Returns:
the color

getColorInt

public static int getColorInt(Color col)
returns the index of the Color within the Colortable

Parameters:
col - the color
Returns:
the index of the color in the colortable

setXf

public void setXf(com.extentech.formats.XLS.Xf xrec)
Sets the internal format to the FormatHandle. For internal use only, not supported.


setHorizontalAlignment

public void setHorizontalAlignment(int align)
Set the horizontal alignment for this FormatHandle

Parameters:
align - - an int representing the alignment. Please review the FormatHandle.ALIGN*** static int's

getHorizontalAlignment

public int getHorizontalAlignment()
Returns an int representing the current horizontal alignment in this FormatHandle. These values are mapped to the FormatHandle.ALIGN*** static int's


setIndent

public void setIndent(int indent)
set indent (1= 3 spaces)

Parameters:
indent -

getIndent

public int getIndent()
return indent (1 = 3 spaces)

Returns:

setVerticalAlignment

public void setVerticalAlignment(int align)
Set the Vertical alignment for this FormatHandle

Parameters:
align - - an int representing the alignment. Please review the FormatHandle.ALIGN*** static int's

getVerticalAlignment

public int getVerticalAlignment()
Returns an int representing the current Vertical alignment in this FormatHandle. These values are mapped to the FormatHandle.ALIGN*** static int's


pack

public FormatHandle pack()
Deprecated. 

DEPRECATED and non functional. Not neccesary as this occurs automatically Consolidates this Format with other identical formats in workbook There is a limit to the number of distinct formats in an Excel workbook. This method allows you to share Formats between identically formatted cells.

Returns:

setWorkBook

public void setWorkBook(com.extentech.formats.XLS.WorkBook bk)
Set the workbook for this FormatHandle

Parameters:
bk -

setWrapText

public void setWrapText(boolean wrapit)
Set the cell wrapping behavior for this FormatHandle. Default is false


getWrapText

public boolean getWrapText()
Get the cell wrapping behavior for this FormatHandle. Default is false


getFontColor

public Color getFontColor()
Get the Font foreground (text) color

Returns:

setCellRotation

public void setCellRotation(int align)
Set the rotation of the cell in degrees. Values 0-90 represent rotation up, 0-90degrees. Values 91-180 represent rotation down, 0-90 degrees. Value 255 is vertical

Parameters:
align - - an int representing the rotation.

getCellRotation

public int getCellRotation()
Get the rotation of the cell. Value 0 means no rotation (horizontal text). Values 1-90 mean rotation up (couter-clockwise) by 1-90 degrees. Values 91-180 mean rotation down (clockwise) by 1-90 degrees. Value 255 means vertical text.


getJSON

public String getJSON(int XFNum)
Get a JSON representation of the format

Parameters:
cr -
Returns:

getJSONObject

public org.json.JSONObject getJSONObject(int XFNum)
Get a JSON representation of the format font height is represented as HTML pt size

Parameters:
cr -
Returns:

getXML

public String getXML(int XFNum)
Returns an XML fragment representing the FormatHandle


getFormatPatternId

public int getFormatPatternId()
Gets the Excel format ID for this format's number format pattern.

Returns:
the Excel format identifier number for the number format pattern

setFormatPatternId

public void setFormatPatternId(int fmt)
Sets the number format pattern based on the format ID number. This method is recommended for advanced users only. In most cases you should use setFormatPattern(String) instead.

Parameters:
fmt - the format ID number for the desired number format pattern

colorToHexString

public static String colorToHexString(Color c)
Convert a java.awt.Color to a hex string.

Returns:
String representation of a Color

HexStringToColorInt

public static int HexStringToColorInt(String s,
                                      short colorType)
convert hex string RGB to Excel colortable int format

Parameters:
s -
colorType -
Returns:

HexStringToColor

public static Color HexStringToColor(String s)
convert hex string RGB to a Color

Parameters:
s -
colorType -
Returns:
Color
See Also:
Color

BorderStringToInt

public static int BorderStringToInt(String s)

getWorkBook

public com.extentech.formats.XLS.WorkBook getWorkBook()

isStyleXf

public boolean isStyleXf()
return truth of "this Xf rec is a style xf"

Returns:

addXf

public int addXf(com.extentech.formats.XLS.Xf sourceXf)
adds all formatting represented by the sourceXf to this workbook, if not already present
This is used internally for transferring formats from one workbook to another

Parameters:
xf - - sourceXf
Returns:
ixfe of added Xf

cloneXf

public static com.extentech.formats.XLS.Xf cloneXf(com.extentech.formats.XLS.Xf xf,
                                                   com.extentech.formats.XLS.WorkBook wkbook)
static version of cloneXf

Parameters:
xf -
wkbook -
Returns:

cloneXf

public static com.extentech.formats.XLS.Xf cloneXf(com.extentech.formats.XLS.Xf xf,
                                                   com.extentech.formats.XLS.Font f,
                                                   com.extentech.formats.XLS.WorkBook wkbook)
static version of cloneXf

Parameters:
xf -
wkbook -
Returns:

setFormatId

public void setFormatId(int x)
set the pointer to the XFE or Conditional format

Parameters:
xfe -


Copyright © 2011 Extentech Inc. All Rights Reserved.