You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

ConditionalFormattingRule.java.svntmp 6.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169
  1. /*
  2. * ====================================================================
  3. * Licensed to the Apache Software Foundation (ASF) under one or more
  4. * contributor license agreements. See the NOTICE file distributed with
  5. * this work for additional information regarding copyright ownership.
  6. * The ASF licenses this file to You under the Apache License, Version 2.0
  7. * (the "License"); you may not use this file except in compliance with
  8. * the License. You may obtain a copy of the License at
  9. *
  10. * http://www.apache.org/licenses/LICENSE-2.0
  11. *
  12. * Unless required by applicable law or agreed to in writing, software
  13. * distributed under the License is distributed on an "AS IS" BASIS,
  14. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  15. * See the License for the specific language governing permissions and
  16. * limitations under the License.
  17. * ====================================================================
  18. */
  19. package org.apache.poi.ss.usermodel;
  20. /**
  21. * Represents a description of a conditional formatting rule
  22. */
  23. public interface ConditionalFormattingRule {
  24. /**
  25. * Create a new border formatting structure if it does not exist,
  26. * otherwise just return existing object.
  27. *
  28. * @return - border formatting object, never returns <code>null</code>.
  29. */
  30. BorderFormatting createBorderFormatting();
  31. /**
  32. * @return - border formatting object if defined, <code>null</code> otherwise
  33. */
  34. BorderFormatting getBorderFormatting();
  35. /**
  36. * Create a new font formatting structure if it does not exist,
  37. * otherwise just return existing object.
  38. *
  39. * @return - font formatting object, never returns <code>null</code>.
  40. */
  41. FontFormatting createFontFormatting();
  42. /**
  43. * @return - font formatting object if defined, <code>null</code> otherwise
  44. */
  45. FontFormatting getFontFormatting();
  46. /**
  47. * Create a new pattern formatting structure if it does not exist,
  48. * otherwise just return existing object.
  49. *
  50. * @return - pattern formatting object, never returns <code>null</code>.
  51. */
  52. PatternFormatting createPatternFormatting();
  53. /**
  54. * @return - pattern formatting object if defined, <code>null</code> otherwise
  55. */
  56. PatternFormatting getPatternFormatting();
  57. /**
  58. * @return - databar / data-bar formatting object if defined, <code>null</code> otherwise
  59. */
  60. DataBarFormatting getDataBarFormatting();
  61. /**
  62. * @return - icon / multi-state formatting object if defined, <code>null</code> otherwise
  63. */
  64. IconMultiStateFormatting getMultiStateFormatting();
  65. /**
  66. * @return color scale / color grate formatting object if defined, <code>null</code> otherwise
  67. */
  68. ColorScaleFormatting getColorScaleFormatting();
  69. /**
  70. * Type of conditional formatting rule.
  71. *
  72. * @return the type of condition
  73. */
  74. ConditionType getConditionType();
  75. /**
  76. * This is null if
  77. * <p>
  78. * <code>{@link #getConditionType()} != {@link ConditionType#FILTER}</code>
  79. * <p>
  80. * This is always {@link ConditionFilterType#FILTER} for HSSF rules of type {@link ConditionType#FILTER}.
  81. * <p>
  82. * For XSSF filter rules, this will indicate the specific type of filter.
  83. *
  84. * @return filter type for filter rules, or null if not a filter rule.
  85. */
  86. ConditionFilterType getConditionFilterType();
  87. /**
  88. * This is null if
  89. * <p>
  90. * <code>{@link #getConditionFilterType()} == null</code>
  91. * <p>
  92. * This means it is always null for HSSF, which does not define the extended condition types.
  93. * <p>
  94. * This object contains the additional configuration information for XSSF filter conditions.
  95. *
  96. * @return
  97. */
  98. public ConditionFilterData getFilterConfiguration();
  99. /**
  100. * The comparison function used when the type of conditional formatting is set to
  101. * {@link ConditionType#CELL_VALUE_IS}
  102. * <p>
  103. * MUST be a constant from {@link ComparisonOperator}
  104. * </p>
  105. *
  106. * @return the conditional format operator
  107. */
  108. byte getComparisonOperation();
  109. /**
  110. * The formula used to evaluate the first operand for the conditional formatting rule.
  111. * <p>
  112. * If the condition type is {@link ConditionType#CELL_VALUE_IS},
  113. * this field is the first operand of the comparison.
  114. * If type is {@link ConditionType#FORMULA}, this formula is used
  115. * to determine if the conditional formatting is applied.
  116. * </p>
  117. * <p>
  118. * If comparison type is {@link ConditionType#FORMULA} the formula MUST be a Boolean function
  119. * </p>
  120. *
  121. * @return the first formula
  122. */
  123. String getFormula1();
  124. /**
  125. * The formula used to evaluate the second operand of the comparison when
  126. * comparison type is {@link ConditionType#CELL_VALUE_IS} and operator
  127. * is either {@link ComparisonOperator#BETWEEN} or {@link ComparisonOperator#NOT_BETWEEN}
  128. *
  129. * @return the second formula
  130. */
  131. String getFormula2();
  132. /**
  133. * HSSF just returns 0, XSSF uses the value stored in the model if present,
  134. * otherwise uses 0.
  135. * <p>
  136. * If priority is 0, just use definition order, as that's how HSSF rules are evaluated.
  137. * <p>
  138. * If a rule is created but not yet added to a sheet, this value may not be valid.
  139. * @return rule priority
  140. */
  141. int getPriority();
  142. /**
  143. * Always true for HSSF rules, optional flag for XSSF rules.
  144. * See Excel help for more.
  145. *
  146. * @return true if conditional formatting rule processing stops when this one is true, false if not
  147. * @see <a href="https://support.office.com/en-us/article/Manage-conditional-formatting-rule-precedence-063cde21-516e-45ca-83f5-8e8126076249">Microsoft Excel help</a>
  148. */
  149. boolean getStopIfTrue();
  150. }