public class FormatCondition
extends java.lang.Object
Example
//Instantiating a Workbook object
Workbook workbook = new Workbook();
Worksheet sheet = workbook.getWorksheets().get(0);
//Adds an empty conditional formatting
int index = sheet.getConditionalFormattings().add();
FormatConditionCollection fcs = sheet.getConditionalFormattings().get(index);
//Sets the conditional format range.
CellArea ca = new CellArea();
ca.StartRow = 0;
ca.EndRow = 0;
ca.StartColumn = 0;
ca.EndColumn = 0;
fcs.addArea(ca);
ca = new CellArea();
ca.StartRow = 1;
ca.EndRow = 1;
ca.StartColumn = 1;
ca.EndColumn = 1;
fcs.addArea(ca);
//Adds condition.
int conditionIndex = fcs.addCondition(FormatConditionType.CELL_VALUE, OperatorType.BETWEEN, "=A2", "100");
//Adds condition.
int conditionIndex2 = fcs.addCondition(FormatConditionType.CELL_VALUE, OperatorType.BETWEEN, "50", "100");
//Sets the background color.
FormatCondition fc = fcs.get(conditionIndex);
fc.getStyle().setBackgroundColor(Color.getRed());
//Saving the Excel file
workbook.save("output.xls");
| Modifier and Type | Method and Description |
|---|---|
AboveAverage |
getAboveAverage()
Get the conditional formatting's "AboveAverage" instance.
|
ColorScale |
getColorScale()
Get the conditional formatting's "ColorScale" instance.
|
DataBar |
getDataBar()
Get the conditional formatting's "DataBar" instance.
|
java.lang.String |
getFormula1()
Gets the value or expression associated with conditional formatting.
|
java.lang.String |
getFormula1(boolean isR1C1,
boolean isLocal)
Gets the value or expression associated with this format condition.
|
java.lang.String |
getFormula1(boolean isR1C1,
boolean isLocal,
int row,
int column)
Gets the value or expression of the conditional formatting of the cell.
|
java.lang.String |
getFormula1(int row,
int column)
Gets the formula of the conditional formatting of the cell.
|
java.lang.String |
getFormula2()
Gets the value or expression associated with conditional formatting.
|
java.lang.String |
getFormula2(boolean isR1C1,
boolean isLocal)
Gets the value or expression associated with this format condition.
|
java.lang.String |
getFormula2(boolean isR1C1,
boolean isLocal,
int row,
int column)
Gets the value or expression of the conditional formatting of the cell.
|
java.lang.String |
getFormula2(int row,
int column)
Gets the formula of the conditional formatting of the cell.
|
IconSet |
getIconSet()
Get the conditional formatting's "IconSet" instance.
|
int |
getOperator()
Gets the conditional format operator type.
|
int |
getPriority()
The priority of this conditional formatting rule.
|
boolean |
getStopIfTrue()
True, no rules with lower priority may be applied over this rule, when this rule evaluates to true.
|
Style |
getStyle()
Gets or setts style of conditional formatted cell ranges.
|
java.lang.String |
getText()
The text value in a "text contains" conditional formatting rule.
|
int |
getTimePeriod()
The applicable time period in a "date occurring鈥? conditional formatting rule.
|
Top10 |
getTop10()
Get the conditional formatting's "Top10" instance.
|
int |
getType()
Gets whether the conditional format Type.
|
void |
setFormula1(java.lang.String value)
Sets the value or expression associated with conditional formatting.
|
void |
setFormula1(java.lang.String formula,
boolean isR1C1,
boolean isLocal)
Sets the value or expression associated with this format condition.
|
void |
setFormula2(java.lang.String value)
Sets the value or expression associated with conditional formatting.
|
void |
setFormula2(java.lang.String formula,
boolean isR1C1,
boolean isLocal)
Sets the value or expression associated with this format condition.
|
void |
setFormulas(java.lang.String formula1,
java.lang.String formula2,
boolean isR1C1,
boolean isLocal)
Sets the value or expression associated with this format condition.
|
void |
setOperator(int value)
Sets the conditional format operator type.
|
void |
setPriority(int value)
The priority of this conditional formatting rule.
|
void |
setStopIfTrue(boolean value)
True, no rules with lower priority may be applied over this rule, when this rule evaluates to true.
|
void |
setStyle(Style value)
Gets or setts style of conditional formatted cell ranges.
|
void |
setText(java.lang.String value)
The text value in a "text contains" conditional formatting rule.
|
void |
setTimePeriod(int value)
The applicable time period in a "date occurring鈥? conditional formatting rule.
|
void |
setType(int value)
Sets whether the conditional format Type.
|
public java.lang.String getFormula1(boolean isR1C1,
boolean isLocal)
isR1C1 - Whether the formula needs to be formatted as R1C1.isLocal - Whether the formula needs to be formatted by locale.public java.lang.String getFormula2(boolean isR1C1,
boolean isLocal)
isR1C1 - Whether the formula needs to be formatted as R1C1.isLocal - Whether the formula needs to be formatted by locale.public java.lang.String getFormula1(boolean isR1C1,
boolean isLocal,
int row,
int column)
Remarks
The given cell must be contained by this conditional formatting, otherwise null will be returned.isR1C1 - Whether the formula needs to be formatted as R1C1.isLocal - Whether the formula needs to be formatted by locale.row - The row index.column - The column index.public java.lang.String getFormula2(boolean isR1C1,
boolean isLocal,
int row,
int column)
Remarks
The given cell must be contained by this conditional formatting, otherwise null will be returned.isR1C1 - Whether the formula needs to be formatted as R1C1.isLocal - Whether the formula needs to be formatted by locale.row - The row index.column - The column index.public void setFormulas(java.lang.String formula1,
java.lang.String formula2,
boolean isR1C1,
boolean isLocal)
formula1 - The value or expression associated with this format condition.
If the input value starts with '=', then it will be taken as formula. Otherwise it will be taken as plain value(text, number, bool).
For text value that starts with '=', user may input it as formula in format: "=\"=...\"".formula2 - The value or expression associated with this format condition. The input format is same with formula1isR1C1 - Whether the formula is R1C1 formula.isLocal - Whether the formula is locale formatted.public void setFormula1(java.lang.String formula,
boolean isR1C1,
boolean isLocal)
formula - The value or expression associated with this format condition.
If the input value starts with '=', then it will be taken as formula. Otherwise it will be taken as plain value(text, number, bool).
For text value that starts with '=', user may input it as formula in format: "=\"=...\"".isR1C1 - Whether the formula is R1C1 formula.isLocal - Whether the formula is locale formatted.public void setFormula2(java.lang.String formula,
boolean isR1C1,
boolean isLocal)
formula - The value or expression associated with this format condition.
If the input value starts with '=', then it will be taken as formula. Otherwise it will be taken as plain value(text, number, bool).
For text value that starts with '=', user may input it as formula in format: "=\"=...\"".isR1C1 - Whether the formula is R1C1 formula.isLocal - Whether the formula is locale formatted.public java.lang.String getFormula1()
Remarks
Please add all areas before setting formula. For setting formula for this condition, if the input value starts with '=', then it will be taken as formula. Otherwise it will be taken as plain value(text, number, bool). For text value that starts with '=', user may input it as formula in format: "=\"=...\"".public void setFormula1(java.lang.String value)
Remarks
Please add all areas before setting formula. For setting formula for this condition, if the input value starts with '=', then it will be taken as formula. Otherwise it will be taken as plain value(text, number, bool). For text value that starts with '=', user may input it as formula in format: "=\"=...\"".public java.lang.String getFormula1(int row,
int column)
row - The row index.column - The column index.public java.lang.String getFormula2()
Remarks
Please add all areas before setting formula. For setting formula for this condition, if the input value starts with '=', then it will be taken as formula. Otherwise it will be taken as plain value(text, number, bool). For text value that starts with '=', user may input it as formula in format: "=\"=...\"".public void setFormula2(java.lang.String value)
Remarks
Please add all areas before setting formula. For setting formula for this condition, if the input value starts with '=', then it will be taken as formula. Otherwise it will be taken as plain value(text, number, bool). For text value that starts with '=', user may input it as formula in format: "=\"=...\"".public java.lang.String getFormula2(int row,
int column)
row - The row index.column - The column index.public int getOperator()
See OperatorType.
public void setOperator(int value)
See OperatorType.
public boolean getStopIfTrue()
public void setStopIfTrue(boolean value)
public int getPriority()
public void setPriority(int value)
public Style getStyle()
public void setStyle(Style value)
public int getType()
See FormatConditionType.
public void setType(int value)
See FormatConditionType.
public IconSet getIconSet()
public DataBar getDataBar()
public ColorScale getColorScale()
public Top10 getTop10()
public AboveAverage getAboveAverage()
public java.lang.String getText()
public void setText(java.lang.String value)
public int getTimePeriod()
See TimePeriodType.
public void setTimePeriod(int value)
See TimePeriodType.
See Also:
Aspose.Cells Documentation - the home page for the Aspose.Cells Product Documentation.
Aspose.Cells Support Forum - our preferred method of support.
We guarantee a prompt response to any inquiry!
© Aspose Pty Ltd 2003-2025. All Rights Reserved.