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.

HSSFEvaluationCell.java 3.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  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.formula.EvaluationCell;
  17. import org.apache.poi.ss.formula.EvaluationSheet;
  18. import org.apache.poi.ss.usermodel.CellType;
  19. import org.apache.poi.util.Internal;
  20. /**
  21. * HSSF wrapper for a cell under evaluation
  22. */
  23. final class HSSFEvaluationCell implements EvaluationCell {
  24. private final EvaluationSheet _evalSheet;
  25. private final HSSFCell _cell;
  26. public HSSFEvaluationCell(HSSFCell cell, EvaluationSheet evalSheet) {
  27. _cell = cell;
  28. _evalSheet = evalSheet;
  29. }
  30. public HSSFEvaluationCell(HSSFCell cell) {
  31. this(cell, new HSSFEvaluationSheet(cell.getSheet()));
  32. }
  33. @Override
  34. public Object getIdentityKey() {
  35. // save memory by just using the cell itself as the identity key
  36. // Note - this assumes HSSFCell has not overridden hashCode and equals
  37. return _cell;
  38. }
  39. public HSSFCell getHSSFCell() {
  40. return _cell;
  41. }
  42. @Override
  43. public boolean getBooleanCellValue() {
  44. return _cell.getBooleanCellValue();
  45. }
  46. /**
  47. * Will return {@link CellType} in a future version of POI.
  48. * For forwards compatibility, do not hard-code cell type literals in your code.
  49. *
  50. * @return cell type
  51. * @deprecated 3.15. Will return a {@link CellType} enum in the future.
  52. */
  53. @Override
  54. public int getCellType() {
  55. return _cell.getCellType();
  56. }
  57. /**
  58. * @since POI 3.15 beta 3
  59. * @deprecated POI 3.15 beta 3.
  60. * Will be deleted when we make the CellType enum transition. See bug 59791.
  61. */
  62. @Override
  63. public CellType getCellTypeEnum() {
  64. return _cell.getCellTypeEnum();
  65. }
  66. @Override
  67. public int getColumnIndex() {
  68. return _cell.getColumnIndex();
  69. }
  70. @Override
  71. public int getErrorCellValue() {
  72. return _cell.getErrorCellValue();
  73. }
  74. @Override
  75. public double getNumericCellValue() {
  76. return _cell.getNumericCellValue();
  77. }
  78. @Override
  79. public int getRowIndex() {
  80. return _cell.getRowIndex();
  81. }
  82. @Override
  83. public EvaluationSheet getSheet() {
  84. return _evalSheet;
  85. }
  86. @Override
  87. public String getStringCellValue() {
  88. return _cell.getRichStringCellValue().getString();
  89. }
  90. /**
  91. * Will return {@link CellType} in a future version of POI.
  92. * For forwards compatibility, do not hard-code cell type literals in your code.
  93. *
  94. * @return cell type of cached formula result
  95. * @deprecated 3.15. Will return a {@link CellType} enum in the future.
  96. */
  97. @Override
  98. public int getCachedFormulaResultType() {
  99. return _cell.getCachedFormulaResultType();
  100. }
  101. /**
  102. * @since POI 3.15 beta 3
  103. * @deprecated POI 3.15 beta 3.
  104. * Will be deleted when we make the CellType enum transition. See bug 59791.
  105. */
  106. @Override
  107. public CellType getCachedFormulaResultTypeEnum() {
  108. return _cell.getCachedFormulaResultTypeEnum();
  109. }
  110. }