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 6.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184
  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 extends DifferentialStyleProvider {
  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. *
  71. * @return number format defined for this rule, or null if the cell default should be used
  72. */
  73. ExcelNumberFormat getNumberFormat();
  74. /**
  75. * Type of conditional formatting rule.
  76. *
  77. * @return the type of condition
  78. */
  79. ConditionType getConditionType();
  80. /**
  81. * This is null if
  82. * <p>
  83. * <code>{@link #getConditionType()} != {@link ConditionType#FILTER}</code>
  84. * <p>
  85. * This is always {@link ConditionFilterType#FILTER} for HSSF rules of type {@link ConditionType#FILTER}.
  86. * <p>
  87. * For XSSF filter rules, this will indicate the specific type of filter.
  88. *
  89. * @return filter type for filter rules, or null if not a filter rule.
  90. */
  91. ConditionFilterType getConditionFilterType();
  92. /**
  93. * This is null if
  94. * <p>
  95. * <code>{@link #getConditionFilterType()} == null</code>
  96. * <p>
  97. * This means it is always null for HSSF, which does not define the extended condition types.
  98. * <p>
  99. * This object contains the additional configuration information for XSSF filter conditions.
  100. *
  101. * @return the Filter Configuration Data, or null if there isn't any
  102. */
  103. public ConditionFilterData getFilterConfiguration();
  104. /**
  105. * The comparison function used when the type of conditional formatting is set to
  106. * {@link ConditionType#CELL_VALUE_IS}
  107. * <p>
  108. * MUST be a constant from {@link ComparisonOperator}
  109. * </p>
  110. *
  111. * @return the conditional format operator
  112. */
  113. byte getComparisonOperation();
  114. /**
  115. * The formula used to evaluate the first operand for the conditional formatting rule.
  116. * <p>
  117. * If the condition type is {@link ConditionType#CELL_VALUE_IS},
  118. * this field is the first operand of the comparison.
  119. * If type is {@link ConditionType#FORMULA}, this formula is used
  120. * to determine if the conditional formatting is applied.
  121. * </p>
  122. * <p>
  123. * If comparison type is {@link ConditionType#FORMULA} the formula MUST be a Boolean function
  124. * </p>
  125. *
  126. * @return the first formula
  127. */
  128. String getFormula1();
  129. /**
  130. * The formula used to evaluate the second operand of the comparison when
  131. * comparison type is {@link ConditionType#CELL_VALUE_IS} and operator
  132. * is either {@link ComparisonOperator#BETWEEN} or {@link ComparisonOperator#NOT_BETWEEN}
  133. *
  134. * @return the second formula
  135. */
  136. String getFormula2();
  137. /**
  138. * XSSF rules store textual condition values as an attribute and also as a formula that needs shifting. Using the attribute is simpler/faster.
  139. * HSSF rules don't have this and return null. We can fall back on the formula for those (AFAIK).
  140. * @return condition text if it exists, or null
  141. */
  142. String getText();
  143. /**
  144. * The priority of the rule, if defined, otherwise 0.
  145. * <p>
  146. * If priority is 0, just use definition order, as that's how older HSSF rules
  147. * are evaluated.
  148. * <p>
  149. * For XSSF, this should always be set. For HSSF, only newer style rules
  150. * have this set, older ones will return 0.
  151. * <p>
  152. * If a rule is created but not yet added to a sheet, this value may not be valid.
  153. * @return rule priority
  154. */
  155. int getPriority();
  156. /**
  157. * Always true for HSSF rules, optional flag for XSSF rules.
  158. * See Excel help for more.
  159. *
  160. * @return true if conditional formatting rule processing stops when this one is true, false if not
  161. * @see <a href="https://support.office.com/en-us/article/Manage-conditional-formatting-rule-precedence-063cde21-516e-45ca-83f5-8e8126076249">Microsoft Excel help</a>
  162. */
  163. boolean getStopIfTrue();
  164. }