Class ConditionalFormattingCollection

  • java.lang.Object
  • All Implemented Interfaces:
    public class ConditionalFormattingCollection 
    extends CollectionBase

Encapsulates a collection of FormatCondition objects.


//Instantiating a Workbook object
Workbook workbook = new Workbook();

Worksheet sheet = workbook.getWorksheets().get(0);

//Get Conditional Formattings
ConditionalFormattingCollection cformattings = sheet.getConditionalFormattings();

//Adds an empty conditional formatting
int index = cformattings.add();

//Get newly added Conditional formatting
FormatConditionCollection fcs = cformattings.get(index);

//Sets the conditional format range.
CellArea ca = new CellArea();

ca.StartRow = 0;

ca.EndRow = 0;

ca.StartColumn = 0;

ca.EndColumn = 0;


ca = new CellArea();

ca.StartRow = 1;

ca.EndRow = 1;

ca.StartColumn = 1;

ca.EndColumn = 1;


//Add condition.
int conditionIndex = fcs.addCondition(FormatConditionType.CELL_VALUE, OperatorType.BETWEEN, "=A2", "100");

//Add condition.
int conditionIndex2 = fcs.addCondition(FormatConditionType.CELL_VALUE, OperatorType.BETWEEN, "50", "100");

//Sets the background color.
FormatCondition fc = fcs.get(conditionIndex);


//Saving the Excel file"C:\\output.xls");

Property Getters/Setters Summary
FormatConditionCollectionget(int index)
Gets the FormatConditions element at the specified index.
Method Summary
Adds a FormatConditions to the collection.
intadd(java.lang.Object value)
Reserved for internal use.
booleancontains(java.lang.Object value)
Reserved for internal use.
voidcopy(ConditionalFormattingCollection cfs)
Copies condtional formattings.
intindexOf(java.lang.Object value)
Reserved for internal use.
voidremoveArea(int startRow, int startColumn, int totalRows, int totalColumns)
Remove all conditional formattings in the range.
voidremoveAt(int index)

    • Property Getters/Setters Detail

      • getCount

        public int getCount()
      • get

        public FormatConditionCollection get(int index)
        Gets the FormatConditions element at the specified index.
        index - The zero based index of the element.
    • Method Detail

      • removeArea

        public void removeArea(int startRow, int startColumn, int totalRows, int totalColumns)
        Remove all conditional formattings in the range.
        startRow - The start row of the range.
        startColumn - The start column of the range.
        totalRows - The number of rows of the range.
        totalColumns - The number of columns of the range.
      • add

        public int add()
        Adds a FormatConditions to the collection.
        FormatConditions object index.
      • clear

        public void clear()
      • removeAt

        public void removeAt(int index)
      • iterator

        public java.util.Iterator iterator()
      • contains

        public boolean contains(java.lang.Object value)
        Reserved for internal use.
      • add

        public int add(java.lang.Object value)
        Reserved for internal use.
      • indexOf

        public int indexOf(java.lang.Object value)
        Reserved for internal use.