com.f1j.ss
Class ConditionalFormat

java.lang.Object
  |
  +--com.actuate.util.Debug
        |
        +--com.f1j.util.Debug
              |
              +--com.f1j.util.ObjConst
                    |
                    +--com.f1j.util.Obj
                          |
                          +--com.f1j.ss.CustomFormat
                                |
                                +--com.f1j.ss.ConditionalFormat

public class ConditionalFormat
extends com.f1j.ss.CustomFormat

This class represents a conditional format condition and the associated formatting. Conditional cell formats are formats that are applied to a cell only when the value of a cell or formula meets a predetermined set of conditions. A range of cells can be formatted with up to three conditional formats. Conditional formats may inclued font colors and styles and cell border colors, styles and patterns.


Field Summary
static short eOperatorBetween
          The format is applied if the cell is greater than or equal to formula1 and less than or equal to formula2.
static short eOperatorEqual
          The format is applied if the cell is equal to formula1.
static short eOperatorGreaterThan
          The format is applied if the cell is greater than formula1.
static short eOperatorGreaterThanOrEqual
          The format is applied if the cell is greater than or equal to formula1.
static short eOperatorLessThan
          The format is applied if the cell is less than formula1.
static short eOperatorLessThanOrEqual
          The format is applied if the cell is less than or equal to formula1.
static short eOperatorNone
          No operator.
static short eOperatorNotBetween
          The format is applied if the cell is less than formula1 or greater than formula2.
static short eOperatorNotEqual
          The format is applied if the cell is not equal to formula1.
static short eTypeCell
          Condition has a type of "Cell".
static short eTypeFormula
          Condition has a type of "Formula".
static short eTypeNone
          No condition type.
 
Constructor Summary
ConditionalFormat(Sheet sheet)
          Creates a new instance of a conditional format.
 
Method Summary
 CellFormat getCellFormat()
          Returns the cell format with the formatting options for this conditional format.
 java.lang.String getFormula1(int row, int col)
          Returns the first formula associated with this conditional format, in US English.
 java.lang.String getFormula1Local(int row, int col)
          Returns the first formula associated with this conditional format, in the user's language.
 java.lang.String getFormula2(int row, int col)
          Returns the second formula associated with this conditional format, in US English.
 java.lang.String getFormula2Local(int row, int col)
          Returns the second formula associated with this conditional format, in the user's language.
 short getOperator()
          Returns the operator for this conditional format.
 short getType()
          Returns the conditional format type associated with this conditional format.
 void setCellFormat(CellFormat cellFormat)
          Sets formatting options for this conditional format from the specified CellFormat object.
 void setEntry1(java.lang.String entry, int row, int col)
          Sets the first entry associated with this conditional format.
 void setEntry2(java.lang.String entry, int row, int col)
          Sets the second entry associated with this conditional format.
 void setFormula1(java.lang.String formula, int row, int col)
          Sets the first formula associated with this conditional format, in US English.
 void setFormula1Local(java.lang.String formula, int row, int col)
          Sets the first formula associated with this conditional format, in the user's language.
 void setFormula2(java.lang.String formula, int row, int col)
          Sets the second formula associated with this conditional format, in US English.
 void setFormula2Local(java.lang.String formula, int row, int col)
          Sets the second formula associated with this conditional format, in the user's language.
 void setOperator(short operator)
          Sets the operator for this conditional format.
 void setType(short type)
          Sets the type of this conditional format.
 

Field Detail

eTypeNone

public static final short eTypeNone
No condition type.

eTypeCell

public static final short eTypeCell
Condition has a type of "Cell". This causes the cell to be compared to the appropriate formula using the specified operator.

eTypeFormula

public static final short eTypeFormula
Condition has a type of "Formula". The first formula is evaluated to determine whether to apply the format. The operator is ignored.

eOperatorNone

public static final short eOperatorNone
No operator.

eOperatorBetween

public static final short eOperatorBetween
The format is applied if the cell is greater than or equal to formula1 and less than or equal to formula2.

eOperatorNotBetween

public static final short eOperatorNotBetween
The format is applied if the cell is less than formula1 or greater than formula2.

eOperatorEqual

public static final short eOperatorEqual
The format is applied if the cell is equal to formula1.

eOperatorNotEqual

public static final short eOperatorNotEqual
The format is applied if the cell is not equal to formula1.

eOperatorGreaterThan

public static final short eOperatorGreaterThan
The format is applied if the cell is greater than formula1.

eOperatorLessThan

public static final short eOperatorLessThan
The format is applied if the cell is less than formula1.

eOperatorGreaterThanOrEqual

public static final short eOperatorGreaterThanOrEqual
The format is applied if the cell is greater than or equal to formula1.

eOperatorLessThanOrEqual

public static final short eOperatorLessThanOrEqual
The format is applied if the cell is less than or equal to formula1.
Constructor Detail

ConditionalFormat

public ConditionalFormat(Sheet sheet)
Creates a new instance of a conditional format.
Parameters:
sheet - the worksheet this conditional format will belong to.
Method Detail

getCellFormat

public CellFormat getCellFormat()
Returns the cell format with the formatting options for this conditional format.

Note: Only the following attributes of cell formatting are supported by conditional formats: bold, italic, strikeout, underline, font color, border, fill pattern, fill foreground and fill background.

Returns:
the CellFormat object with the format attributes for this conditional format.
See Also:
setCellFormat(com.f1j.ss.CellFormat), CellFormat

getFormula1

public java.lang.String getFormula1(int row,
                                    int col)
Returns the first formula associated with this conditional format, in US English.
Parameters:
row - the row this formula is relative to.
col - the column this formula is relative to.
Returns:
the formula. Returns null if there is no formula.
See Also:
getFormula1Local(int, int), getFormula2(int, int)

getFormula1Local

public java.lang.String getFormula1Local(int row,
                                         int col)
Returns the first formula associated with this conditional format, in the user's language.
Parameters:
row - the row this formula is relative to.
col - the column this formula is relative to.
Returns:
the formula. Returns null if there is no formula.
See Also:
getFormula1(int, int), getFormula2Local(int, int)

getFormula2

public java.lang.String getFormula2(int row,
                                    int col)
Returns the second formula associated with this conditional format, in US English.
Parameters:
row - the row this formula is relative to.
col - the column this formula is relative to.
Returns:
the formula. Returns null if there is no formula.
See Also:
getFormula1(int, int), getFormula2Local(int, int)

getFormula2Local

public java.lang.String getFormula2Local(int row,
                                         int col)
Returns the second formula associated with this conditional format, in the user's language.
Parameters:
row - the row this formula is relative to.
col - the column this formula is relative to.
Returns:
the formula. Returns null if there is no formula.
See Also:
getFormula1Local(int, int), getFormula2(int, int)

getType

public short getType()
Returns the conditional format type associated with this conditional format.
Returns:
a short indicating the type of this conditional format: eTypeNone, eTypeCell or eTypeFormula.
See Also:
setType(short)

getOperator

public short getOperator()
Returns the operator for this conditional format.
Returns:
a short indicating the operator.
See Also:
setOperator(short)

setCellFormat

public void setCellFormat(CellFormat cellFormat)
                   throws F1Exception
Sets formatting options for this conditional format from the specified CellFormat object.

Note: Only the following attributes of cell formatting are supported by conditional formats: bold, italic, strikeout, underline, font color, border, fill pattern, fill foreground and fill background.

Parameters:
cellFormat - the formatting to apply to this conditional format.
Throws:
F1Exception - if an exception occurs.
See Also:
getCellFormat(), CellFormat

setEntry1

public void setEntry1(java.lang.String entry,
                      int row,
                      int col)
               throws F1Exception
Sets the first entry associated with this conditional format.
Parameters:
entry - the first entry for this conditional format.
row - the row which the formula will be relative to.
col - the column which the formula will be relative to.
Throws:
F1Exception - if there is an error in the formula.
See Also:
setEntry2(java.lang.String, int, int)

setEntry2

public void setEntry2(java.lang.String entry,
                      int row,
                      int col)
               throws F1Exception
Sets the second entry associated with this conditional format.
Parameters:
entry - the first entry for this conditional format.
row - the row the formula will be relative to.
col - the column the formula will be relative to.
Throws:
F1Exception - if there is an error in the formula.
See Also:
setEntry1(java.lang.String, int, int)

setFormula1

public void setFormula1(java.lang.String formula,
                        int row,
                        int col)
                 throws F1Exception
Sets the first formula associated with this conditional format, in US English.
Parameters:
formula - the first formula for this conditional format.
row - the row the formula will be relative to.
col - the column the formula will be relative to.
Throws:
F1Exception - if there is an error in the formula.
See Also:
setFormula1Local(java.lang.String, int, int), setFormula2(java.lang.String, int, int)

setFormula1Local

public void setFormula1Local(java.lang.String formula,
                             int row,
                             int col)
                      throws F1Exception
Sets the first formula associated with this conditional format, in the user's language.
Parameters:
formula - the first formula for this conditional format.
row - the row the formula will be relative to.
col - the column the formula will be relative to.
Throws:
F1Exception - if there is an error in the formula.
See Also:
setFormula1(java.lang.String, int, int), setFormula2Local(java.lang.String, int, int)

setFormula2

public void setFormula2(java.lang.String formula,
                        int row,
                        int col)
                 throws F1Exception
Sets the second formula associated with this conditional format, in US English.
Parameters:
formula - the second formula for this conditional format.
row - the row the formula will be relative to.
col - the column the formula will be relative to.
Throws:
F1Exception - if there is an error in the formula.
See Also:
setFormula1(java.lang.String, int, int), setFormula2Local(java.lang.String, int, int)

setFormula2Local

public void setFormula2Local(java.lang.String formula,
                             int row,
                             int col)
                      throws F1Exception
Sets the second formula associated with this conditional format, in the user's language.
Parameters:
formula - the second formula for this conditional format.
row - the row the formula will be relative to.
col - the column the formula will be relative to.
Throws:
F1Exception - if there is an error in the formula.
See Also:
setFormula1Local(java.lang.String, int, int), setFormula2(java.lang.String, int, int)

setOperator

public void setOperator(short operator)
Sets the operator for this conditional format.
Parameters:
operator - the operator for this conditional format:
Conditional Format Operators
eOperatorNone eOperatorBetween eOperatorNotBetween
eOperatorEqual eOperatorNotEqual eOperatorGreaterThan
eOperatorLessThan eOperatorGreaterThanOrEqual eOperatorLessThanOrEqual
See Also:
getOperator()

setType

public void setType(short type)
Sets the type of this conditional format.
Parameters:
type - a short indicating the type of this conditional format: eTypeNone, eTypeCell or eTypeFormula.
See Also:
getType()