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.

XSSFEvaluationCell.java 3.5KB

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