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.

HSSFDataValidationHelper.java 4.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  1. /* ====================================================================
  2. Licensed to the Apache Software Foundation (ASF) under one or more
  3. contributor license agreements. See the NOTICE file distributed with
  4. this work for additional information regarding copyright ownership.
  5. The ASF licenses this file to You under the Apache License, Version 2.0
  6. (the "License"); you may not use this file except in compliance with
  7. the License. You may obtain a copy of the License at
  8. http://www.apache.org/licenses/LICENSE-2.0
  9. Unless required by applicable law or agreed to in writing, software
  10. distributed under the License is distributed on an "AS IS" BASIS,
  11. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. See the License for the specific language governing permissions and
  13. limitations under the License.
  14. ==================================================================== */
  15. package org.apache.poi.hssf.usermodel;
  16. import org.apache.poi.ss.usermodel.DataValidation;
  17. import org.apache.poi.ss.usermodel.DataValidationConstraint;
  18. import org.apache.poi.ss.usermodel.DataValidationHelper;
  19. import org.apache.poi.ss.usermodel.DataValidationConstraint.ValidationType;
  20. import org.apache.poi.ss.util.CellRangeAddressList;
  21. /**
  22. * Helper for working with Data Validation
  23. */
  24. public class HSSFDataValidationHelper implements DataValidationHelper {
  25. // Findbugs: URF_UNREAD_FIELD . Do not delete without understanding how this class works.
  26. //private HSSFSheet sheet;
  27. public HSSFDataValidationHelper(HSSFSheet sheet) {
  28. super();
  29. // Findbugs: URF_UNREAD_FIELD . Do not delete without understanding how this class works.
  30. //this.sheet = sheet;
  31. }
  32. /*
  33. * (non-Javadoc)
  34. *
  35. * @see
  36. * org.apache.poi.ss.usermodel.DataValidationHelper#createDateConstraint
  37. * (int, java.lang.String, java.lang.String, java.lang.String)
  38. */
  39. public DataValidationConstraint createDateConstraint(int operatorType, String formula1, String formula2, String dateFormat) {
  40. return DVConstraint.createDateConstraint(operatorType, formula1, formula2, dateFormat);
  41. }
  42. /*
  43. * (non-Javadoc)
  44. *
  45. * @see
  46. * org.apache.poi.ss.usermodel.DataValidationHelper#createExplicitListConstraint
  47. * (java.lang.String[])
  48. */
  49. public DataValidationConstraint createExplicitListConstraint(String[] listOfValues) {
  50. return DVConstraint.createExplicitListConstraint(listOfValues);
  51. }
  52. /*
  53. * (non-Javadoc)
  54. *
  55. * @see
  56. * org.apache.poi.ss.usermodel.DataValidationHelper#createFormulaListConstraint
  57. * (java.lang.String)
  58. */
  59. public DataValidationConstraint createFormulaListConstraint(String listFormula) {
  60. return DVConstraint.createFormulaListConstraint(listFormula);
  61. }
  62. public DataValidationConstraint createNumericConstraint(int validationType,int operatorType, String formula1, String formula2) {
  63. return DVConstraint.createNumericConstraint(validationType, operatorType, formula1, formula2);
  64. }
  65. public DataValidationConstraint createIntegerConstraint(int operatorType, String formula1, String formula2) {
  66. return DVConstraint.createNumericConstraint(ValidationType.INTEGER, operatorType, formula1, formula2);
  67. }
  68. /*
  69. * (non-Javadoc)
  70. *
  71. * @see
  72. * org.apache.poi.ss.usermodel.DataValidationHelper#createNumericConstraint
  73. * (int, java.lang.String, java.lang.String)
  74. */
  75. public DataValidationConstraint createDecimalConstraint(int operatorType, String formula1, String formula2) {
  76. return DVConstraint.createNumericConstraint(ValidationType.DECIMAL, operatorType, formula1, formula2);
  77. }
  78. /*
  79. * (non-Javadoc)
  80. *
  81. * @see
  82. * org.apache.poi.ss.usermodel.DataValidationHelper#createTextLengthConstraint
  83. * (int, java.lang.String, java.lang.String)
  84. */
  85. public DataValidationConstraint createTextLengthConstraint(int operatorType, String formula1, String formula2) {
  86. return DVConstraint.createNumericConstraint(ValidationType.TEXT_LENGTH, operatorType, formula1, formula2);
  87. }
  88. /*
  89. * (non-Javadoc)
  90. *
  91. * @see
  92. * org.apache.poi.ss.usermodel.DataValidationHelper#createTimeConstraint
  93. * (int, java.lang.String, java.lang.String, java.lang.String)
  94. */
  95. public DataValidationConstraint createTimeConstraint(int operatorType, String formula1, String formula2) {
  96. return DVConstraint.createTimeConstraint(operatorType, formula1, formula2);
  97. }
  98. public DataValidationConstraint createCustomConstraint(String formula) {
  99. return DVConstraint.createCustomFormulaConstraint(formula);
  100. }
  101. /*
  102. * (non-Javadoc)
  103. *
  104. * @see
  105. * org.apache.poi.ss.usermodel.DataValidationHelper#createValidation(org
  106. * .apache.poi.ss.usermodel.DataValidationConstraint,
  107. * org.apache.poi.ss.util.CellRangeAddressList)
  108. */
  109. public DataValidation createValidation(DataValidationConstraint constraint, CellRangeAddressList cellRangeAddressList) {
  110. return new HSSFDataValidation(cellRangeAddressList, constraint);
  111. }
  112. }