public class FormatConditionCollection
extends java.lang.Object
Example
//Create a new Workbook.
Workbook workbook = new Workbook();
//Get the first worksheet.
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 |
|---|---|
int[] |
add(CellArea cellArea,
int type,
int operatorType,
java.lang.String formula1,
java.lang.String formula2)
Adds a formatting condition and effected cell rang to the FormatConditions
The FormatConditions can contain up to three conditional formats.
|
int |
addArea(CellArea cellArea)
Adds a conditional formatted cell range.
|
int |
addCondition(int type)
Add a format condition.
|
int |
addCondition(int type,
int operatorType,
java.lang.String formula1,
java.lang.String formula2)
Adds a formatting condition.
|
FormatCondition |
get(int index)
Gets the formatting condition by index.
|
CellArea |
getCellArea(int index)
Gets the conditional formatted cell range by index.
|
int |
getCount()
Gets the count of the conditions.
|
int |
getRangeCount()
Gets count of conditionally formatted ranges.
|
void |
removeArea(int index)
Removes conditional formatted cell range by index.
|
boolean |
removeArea(int startRow,
int startColumn,
int totalRows,
int totalColumns)
Remove conditional formatting int the range.
|
void |
removeCondition(int index)
Removes the formatting condition by index.
|
public int[] add(CellArea cellArea, int type, int operatorType, java.lang.String formula1, java.lang.String formula2)
cellArea - Conditional formatted cell range.type - FormatConditionType. Type of conditional formatting.It could be one of the members of FormatConditionType.operatorType - OperatorType. Comparison operator.It could be one of the members of OperatorType.formula1 - The value or expression associated with conditional formatting.formula2 - The value or expression associated with conditional formattingpublic int addArea(CellArea cellArea)
cellArea - Conditional formatted cell range.public int addCondition(int type,
int operatorType,
java.lang.String formula1,
java.lang.String formula2)
type - FormatConditionType. The type of format condition.operatorType - OperatorType. The operator typeformula1 - The value or expression associated with conditional formatting.
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 conditional formatting.
The input format is same with formula1public int addCondition(int type)
type - FormatConditionType. Format condition type.public int getCount()
public int getRangeCount()
public FormatCondition get(int index)
index - the index of the formatting condition to return.public CellArea getCellArea(int index)
index - the index of the conditional formatted cell range.public void removeArea(int index)
index - The index of the conditional formatted cell range to be removed.public boolean removeArea(int startRow,
int startColumn,
int totalRows,
int totalColumns)
startRow - The startRow of the range.startColumn - The startColumn of the range.totalRows - The number of rows of the range.totalColumns - The number of columns of the range.public void removeCondition(int index)
index - The index of the formatting condition to be removed.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.