com.aspose.cells
Class FormatConditionCollection

java.lang.Object
    extended by com.aspose.cells.FormatConditionCollection

public class FormatConditionCollection 
extends java.lang.Object

Represents conditional formatting. The FormatConditions can contain up to three conditional formats.

Example:

//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("C:\\output.xls");

Property Getters/Setters Summary
intgetCount()
           Gets the count of the conditions.
intgetRangeCount()
           Gets count of conditionally formatted ranges.
FormatConditionget(int index)
           Gets the formatting conidition by index.
 
Method Summary
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. References to the other sheets are not allowed in the formulas of conditional formattin
intaddArea(CellArea cellArea)
           Adds a conditional formatted cell range.
intaddCondition(int type)
           Add a format condition.
intaddCondition(int type, int operatorType, java.lang.String formula1, java.lang.String formula2)
           Adds a formatting condition.
CellAreagetCellArea(int index)
           Gets the conditional formatted cell range by index.
voidremoveArea(int index)
           Removes conditional formatted cell range by index.
booleanremoveArea(int startRow, int startColumn, int totalRows, int totalColumns)
           Remove conditional formatting int the range.
voidremoveCondition(int index)
           Removes the formatting condition by index.
 

Property Getters/Setters Detail

getCount

public int getCount()
Gets the count of the conditions.

getRangeCount

public int getRangeCount()
Gets count of conditionally formatted ranges.

get

public FormatCondition get(int index)
Gets the formatting conidition by index.
Parameters:
index - the index of the formatting conidition to return.
Returns:
the formatting conidition

Method Detail

add

public 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. References to the other sheets are not allowed in the formulas of conditional formattin OperatorType
Parameters:
cellArea - Conditional formatted cell range.
type - A FormatConditionType value. Type of conditional formatting.It could be one of the members of FormatConditionType.
operatorType - A OperatorType value. 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 formatting
Returns:
[0]:Formatting condition object index;[1] Effected cell rang index.

addArea

public int addArea(CellArea cellArea)
Adds a conditional formatted cell range.
Parameters:
cellArea - Conditional formatted cell range.
Returns:
Conditional formatted cell rang index.

addCondition

public int addCondition(int type, int operatorType, java.lang.String formula1, java.lang.String formula2)
Adds a formatting condition.
Parameters:
type - A FormatConditionType value. of conditinal formatting.It could be one of the members of FormatConditionType.
operatorType - A OperatorType value. The comparison OperatorType.It could be one of the members of OperatorType.
formula1 - The value or expression associated with conditinal formatting.
formula2 - The value or expression associated with conditinal formatting.
Returns:
Formatting condition object index;

addCondition

public int addCondition(int type)
Add a format condition.
Parameters:
type - A FormatConditionType value. Format condition type.
Returns:
Formatting condition object index;

getCellArea

public CellArea getCellArea(int index)
Gets the conditional formatted cell range by index.
Parameters:
index - the index of the coditional formatted cell range.
Returns:
the conditional formatted cell range

removeArea

public void removeArea(int index)
Removes conditional formatted cell range by index.
Parameters:
index - The index of the conditional formatted cell range to be removed.

removeArea

public boolean removeArea(int startRow, int startColumn, int totalRows, int totalColumns)
Remove conditional formatting int the range.
Parameters:
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.
Returns:
Returns TRUE, this FormatCondtionCollection should be removed.

removeCondition

public void removeCondition(int index)
Removes the formatting condition by index.
Parameters:
index - The index of the formatting condition to be removed.

See Also:
          Aspose.Cells Documentation - the home page for the Aspose.Cellss Product Documentation.
          Aspose.Cells Support Forum - our preferred method of support.