Example:
# Instantiating a Workbook object workbook = Workbook() sheet = workbook.getWorksheets().get(0) # Adds an empty conditional formatting index = sheet.getConditionalFormattings().add() fcs = sheet.getConditionalFormattings().get(index) # Sets the conditional format range. ca = CellArea() ca.StartRow = 0 ca.EndRow = 0 ca.StartColumn = 0 ca.EndColumn = 0 fcs.addArea(ca) ca = CellArea() ca.StartRow = 1 ca.EndRow = 1 ca.StartColumn = 1 ca.EndColumn = 1 fcs.addArea(ca) # Adds condition. conditionIndex = fcs.addCondition(FormatConditionType.CELL_VALUE, OperatorType.BETWEEN, "=A2", "100") # Adds condition. conditionIndex2 = fcs.addCondition(FormatConditionType.CELL_VALUE, OperatorType.BETWEEN, "50", "100") # Sets the background color. fc = fcs.get(conditionIndex) fc.getStyle().setBackgroundColor(Color.getRed()) # Saving the Excel file workbook.save("Book1.xls")
Property Getters/Setters Summary | ||
---|---|---|
method | getAboveAverage() | |
Get the conditional formatting's "AboveAverage" instance.
The default instance's rule highlights cells that are
above the average for all values in the range.
Valid only for type = AboveAverage.
|
||
method | getColorScale() | |
Get the conditional formatting's "ColorScale" instance.
The default instance is a "green-yellow-red" 3ColorScale .
Valid only for type = ColorScale.
|
||
method | getDataBar() | |
Get the conditional formatting's "DataBar" instance.
The default instance's color is blue.
Valid only for type is DataBar.
|
||
method | getFormula1() | |
method | setFormula1(value) | |
Gets and sets the value or expression associated with conditional formatting. | ||
method | getFormula2() | |
method | setFormula2(value) | |
Gets and sets the value or expression associated with conditional formatting. | ||
method | getIconSet() | |
Get the conditional formatting's "IconSet" instance.
The default instance's IconSetType is TrafficLights31.
Valid only for type = IconSet.
|
||
method | getOperator() | |
method | setOperator(value) | |
Gets and sets the conditional format operator type. The value of the property is OperatorType integer constant. | ||
method | getPriority() | |
method | setPriority(value) | |
The priority of this conditional formatting rule. This value is used to determine which format should be evaluated and rendered. Lower numeric values are higher priority than higher numeric values, where '1' is the highest priority. | ||
method | getStopIfTrue() | |
method | setStopIfTrue(value) | |
True, no rules with lower priority may be applied over this rule, when this rule evaluates to true. Only applies for Excel 2007; | ||
method | getStyle() | |
method | setStyle(value) | |
Gets or setts style of conditional formatted cell ranges. | ||
method | getText() | |
method | setText(value) | |
The text value in a "text contains" conditional formatting rule. Valid only for type = containsText, notContainsText, beginsWith and endsWith. The default value is null. | ||
method | getTimePeriod() | |
method | setTimePeriod(value) | |
The applicable time period in a "date occurring…" conditional formatting rule. Valid only for type = timePeriod. The default value is TimePeriodType.Today. The value of the property is TimePeriodType integer constant. | ||
method | getTop10() | |
Get the conditional formatting's "Top10" instance.
The default instance's rule highlights cells whose
values fall in the top 10 bracket.
Valid only for type is Top10.
|
||
method | getType() | |
method | setType(value) | |
Gets and sets whether the conditional format Type. The value of the property is FormatConditionType integer constant. |
Method Summary | ||
---|---|---|
method | getFormula1(isR1C1, isLocal) | |
Gets the value or expression associated with this format condition.
|
||
method | getFormula1(isR1C1, isLocal, row, column) | |
Gets the value or expression of the conditional formatting of the cell.
|
||
method | getFormula1(row, column) | |
Gets the formula of the conditional formatting of the cell.
|
||
method | getFormula2(isR1C1, isLocal) | |
Gets the value or expression associated with this format condition.
|
||
method | getFormula2(isR1C1, isLocal, row, column) | |
Gets the value or expression of the conditional formatting of the cell.
|
||
method | getFormula2(row, column) | |
Gets the formula of the conditional formatting of the cell.
|
||
method | setFormula1(formula, isR1C1, isLocal) | |
Sets the value or expression associated with this format condition.
|
||
method | setFormula2(formula, isR1C1, isLocal) | |
Sets the value or expression associated with this format condition.
|
||
method | setFormulas(formula1, formula2, isR1C1, isLocal) | |
Sets the value or expression associated with this format condition.
|
String getFormula1() / setFormula1(value)
String getFormula2() / setFormula2(value)
int getOperator() / setOperator(value)
boolean getStopIfTrue() / setStopIfTrue(value)
int getPriority() / setPriority(value)
Style getStyle() / setStyle(value)
int getType() / setType(value)
IconSet getIconSet()
DataBar getDataBar()
ColorScale getColorScale()
Top10 getTop10()
AboveAverage getAboveAverage()
String getText() / setText(value)
int getTimePeriod() / setTimePeriod(value)
String getFormula1(isR1C1, isLocal)
isR1C1: boolean
- Whether the formula needs to be formatted as R1C1.isLocal: boolean
- Whether the formula needs to be formatted by locale.String getFormula2(isR1C1, isLocal)
isR1C1: boolean
- Whether the formula needs to be formatted as R1C1.isLocal: boolean
- Whether the formula needs to be formatted by locale.String getFormula1(isR1C1, isLocal, row, column)
isR1C1: boolean
- Whether the formula needs to be formatted as R1C1.isLocal: boolean
- Whether the formula needs to be formatted by locale.row: int
- The row index.column: int
- The column index.String getFormula2(isR1C1, isLocal, row, column)
isR1C1: boolean
- Whether the formula needs to be formatted as R1C1.isLocal: boolean
- Whether the formula needs to be formatted by locale.row: int
- The row index.column: int
- The column index.setFormulas(formula1, formula2, isR1C1, isLocal)
formula1: String
- 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: String
- The value or expression associated with this format condition. The input format is same with formula1isR1C1: boolean
- Whether the formula is R1C1 formula.isLocal: boolean
- Whether the formula is locale formatted.setFormula1(formula, isR1C1, isLocal)
formula: String
- 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: boolean
- Whether the formula is R1C1 formula.isLocal: boolean
- Whether the formula is locale formatted.setFormula2(formula, isR1C1, isLocal)
formula: String
- 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: boolean
- Whether the formula is R1C1 formula.isLocal: boolean
- Whether the formula is locale formatted.String getFormula1(row, column)
row: int
- The row index.column: int
- The column index.String getFormula2(row, column)
row: int
- The row index.column: int
- The column index.