Example:
# Instantiating a Workbook object workbook = Workbook() sheet = workbook.getWorksheets().get(0) # Get Conditional Formattings cformattings = sheet.getConditionalFormattings() # Adds an empty conditional formatting index = cformattings.add() # Get newly added Conditional formatting fcs = cformattings.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) # Add condition. conditionIndex = fcs.addCondition(FormatConditionType.CELL_VALUE, OperatorType.BETWEEN, "=A2", "100") # Add 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 | getCount() | |
method | get(index) | |
Gets the FormatConditions element at the specified index.
|
Method Summary | ||
---|---|---|
method | add() | |
Adds a FormatConditions to the collection.
|
||
method | add(value) | |
Reserved for internal use. |
||
method | clear() | |
method | contains(value) | |
Reserved for internal use. |
||
method | copy(cfs) | |
Copies conditional formatting.
|
||
method | get(index) | |
Reserved for internal use. |
||
method | indexOf(value) | |
Reserved for internal use. |
||
method | iterator() | |
method | removeArea(startRow, startColumn, totalRows, totalColumns) | |
Remove all conditional formatting in the range.
|
||
method | removeAt(index) | |
int getCount()
FormatConditionCollection get(index)
index
- The zero based index of the element.removeArea(startRow, startColumn, totalRows, totalColumns)
startRow: int
- The start row of the range.startColumn: int
- The start column of the range.totalRows: int
- The number of rows of the range.totalColumns: int
- The number of columns of the range.copy(cfs)
cfs: ConditionalFormattingCollection
- The conditional formattingint add()
clear()
removeAt(index)
Iterator iterator()
Object get(index)
boolean contains(value)
int add(value)
int indexOf(value)