com.jxcell
Class ConditionFormat

java.lang.Object
  extended by com.jxcell.ConditionFormat

public class ConditionFormat
extends java.lang.Object

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 OperatorBetween
          The format is applied if the cell is greater than or equal to formula1 and less than or equal to formula2.
static short OperatorEqual
          The format is applied if the cell is equal to formula1.
static short OperatorGreaterThan
          The format is applied if the cell is greater than formula1.
static short OperatorGreaterThanOrEqual
          The format is applied if the cell is greater than or equal to formula1.
static short OperatorLessThan
          The format is applied if the cell is less than formula1.
static short OperatorLessThanOrEqual
          The format is applied if the cell is less than or equal to formula1.
static short OperatorNone
          No operator.
static short OperatorNotBetween
          The format is applied if the cell is less than formula1 or greater than formula2.
static short OperatorNotEqual
          The format is applied if the cell is not equal to formula1.
static short TypeCell
          Condition has a type of "Cell".
static short TypeFormula
          Condition has a type of "Formula".
static short TypeNone
          No condition type.
 
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
 java.lang.String getFormula2(int row, int col)
          Returns the second formula associated with this conditional format
 short getOperator()
          Returns the operator for this conditional format.
 short getType()
          Returns the conditional format type associated with this conditional format.
 void setCellFormat(CellFormat cfmt)
          Sets formatting options for this conditional format from the specified RangeStyle object.
 void setFormula1(java.lang.String formula, int row, int col)
          Sets the first formula associated with this conditional format
 void setFormula2(java.lang.String formula, int row, int col)
          Sets the second formula associated with this conditional format
 void setOperator(short operator)
          Sets the operator for this conditional format.
 void setType(short type)
          Sets the type of this conditional format.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

TypeNone

public static final short TypeNone
No condition type.

See Also:
Constant Field Values

TypeCell

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

See Also:
Constant Field Values

TypeFormula

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

See Also:
Constant Field Values

OperatorNone

public static final short OperatorNone
No operator.

See Also:
Constant Field Values

OperatorBetween

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

See Also:
Constant Field Values

OperatorNotBetween

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

See Also:
Constant Field Values

OperatorEqual

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

See Also:
Constant Field Values

OperatorNotEqual

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

See Also:
Constant Field Values

OperatorGreaterThan

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

See Also:
Constant Field Values

OperatorLessThan

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

See Also:
Constant Field Values

OperatorGreaterThanOrEqual

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

See Also:
Constant Field Values

OperatorLessThanOrEqual

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

See Also:
Constant Field Values
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 RangeStyle object with the format attributes for this conditional format.

setCellFormat

public void setCellFormat(CellFormat cfmt)
                   throws java.lang.Exception
Sets formatting options for this conditional format from the specified RangeStyle 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:
cfmt - the formatting to apply to this conditional format.
Throws:
java.lang.Exception - exception

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.

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.

getOperator

public short getOperator()
Returns the operator for this conditional format.

Returns:
a short indicating the operator.

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

getFormula1

public java.lang.String getFormula1(int row,
                                    int col)
                             throws java.lang.Exception
Returns the first formula associated with this conditional format

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.
Throws:
java.lang.Exception - exception

setFormula1

public void setFormula1(java.lang.String formula,
                        int row,
                        int col)
                 throws java.lang.Exception
Sets the first formula associated with this conditional format

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:
java.lang.Exception - if there is an error in the formula.

getFormula2

public java.lang.String getFormula2(int row,
                                    int col)
                             throws java.lang.Exception
Returns the second formula associated with this conditional format

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.
Throws:
java.lang.Exception - exception

setFormula2

public void setFormula2(java.lang.String formula,
                        int row,
                        int col)
                 throws java.lang.Exception
Sets the second formula associated with this conditional format

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:
java.lang.Exception - if there is an error in the formula.