/**
  * A factory method allowing to create a conditional formatting rule with a formula.<br>
  *
  * @param formula - formula for the valued, compared with the cell
  */
 public XSSFConditionalFormattingRule createConditionalFormattingRule(String formula) {
   XSSFConditionalFormattingRule rule = new XSSFConditionalFormattingRule(_sheet);
   CTCfRule cfRule = rule.getCTCfRule();
   cfRule.addFormula(formula);
   cfRule.setType(STCfType.EXPRESSION);
   return rule;
 }
  /**
   * A factory method allowing to create a conditional formatting rule with a cell comparison
   * operator
   *
   * <p>TODO - formulas containing cell references are currently not parsed properly
   *
   * @param comparisonOperation - a constant value from <tt>{@link
   *     org.apache.poi.hssf.record.CFRuleBase.ComparisonOperator}</tt>:
   *     <p>
   *     <ul>
   *       <li>BETWEEN
   *       <li>NOT_BETWEEN
   *       <li>EQUAL
   *       <li>NOT_EQUAL
   *       <li>GT
   *       <li>LT
   *       <li>GE
   *       <li>LE
   *     </ul>
   *
   * @param formula1 - formula for the valued, compared with the cell
   * @param formula2 - second formula (only used with {@link
   *     org.apache.poi.ss.usermodel.ComparisonOperator#BETWEEN}) and {@link
   *     org.apache.poi.ss.usermodel.ComparisonOperator#NOT_BETWEEN} operations)
   */
  public XSSFConditionalFormattingRule createConditionalFormattingRule(
      byte comparisonOperation, String formula1, String formula2) {

    XSSFConditionalFormattingRule rule = new XSSFConditionalFormattingRule(_sheet);
    CTCfRule cfRule = rule.getCTCfRule();
    cfRule.addFormula(formula1);
    if (formula2 != null) cfRule.addFormula(formula2);
    cfRule.setType(STCfType.CELL_IS);
    STConditionalFormattingOperator.Enum operator;
    switch (comparisonOperation) {
      case ComparisonOperator.BETWEEN:
        operator = STConditionalFormattingOperator.BETWEEN;
        break;
      case ComparisonOperator.NOT_BETWEEN:
        operator = STConditionalFormattingOperator.NOT_BETWEEN;
        break;
      case ComparisonOperator.LT:
        operator = STConditionalFormattingOperator.LESS_THAN;
        break;
      case ComparisonOperator.LE:
        operator = STConditionalFormattingOperator.LESS_THAN_OR_EQUAL;
        break;
      case ComparisonOperator.GT:
        operator = STConditionalFormattingOperator.GREATER_THAN;
        break;
      case ComparisonOperator.GE:
        operator = STConditionalFormattingOperator.GREATER_THAN_OR_EQUAL;
        break;
      case ComparisonOperator.EQUAL:
        operator = STConditionalFormattingOperator.EQUAL;
        break;
      case ComparisonOperator.NOT_EQUAL:
        operator = STConditionalFormattingOperator.NOT_EQUAL;
        break;
      default:
        throw new IllegalArgumentException("Unknown comparison operator: " + comparisonOperation);
    }
    cfRule.setOperator(operator);

    return rule;
  }