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) | → inherited from CollectionBase |
Reserved for internal use. | ||
method | clear() | → inherited from CollectionBase |
method | contains(value) | → inherited from CollectionBase |
Reserved for internal use. | ||
method | copy(cfs) | |
Copies condtional formattings. | ||
method | get(index) | → inherited from CollectionBase |
Reserved for internal use. | ||
method | indexOf(value) | → inherited from CollectionBase |
Reserved for internal use. | ||
method | iterator() | → inherited from CollectionBase |
method | removeArea(startRow, startColumn, totalRows, totalColumns) | |
Remove all conditional formattings in the range. | ||
method | removeAt(index) | → inherited from CollectionBase |
Property Getters/Setters Detail |
---|
getCount : int | |
int getCount() |
get : FormatConditionCollection | |
FormatConditionCollection get(index) |
index
- The zero based index of the element.Method Detail |
---|
removeArea | |
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 | |
copy(cfs) |
cfs: ConditionalFormattingCollection
- The condtional formattingsadd | |
int add() |
clear | |
clear() |
removeAt | |
removeAt(index) |
iterator | |
Iterator iterator() |
get | |
Object get(index) |
contains | |
boolean contains(value) |
add | |
int add(value) |
indexOf | |
int indexOf(value) |