From: Nick Burch Date: Sat, 1 Aug 2015 21:34:34 +0000 (+0000) Subject: Use the same "is this a formula" logic for both getCellType and getCachedFormulaResul... X-Git-Tag: REL_3_13_FINAL~179 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=b0fa6ed2f355beb73cc3135d1af7a9ef53981542;p=poi.git Use the same "is this a formula" logic for both getCellType and getCachedFormulaResultType git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1693767 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFCell.java b/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFCell.java index 5c16f05e8b..bb57f65c6e 100644 --- a/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFCell.java +++ b/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFCell.java @@ -536,6 +536,13 @@ public final class XSSFCell implements Cell { _cell.setS(idx); } } + + private boolean isFormulaCell() { + if (_cell.getF() != null || getSheet().isCellInArrayFormulaContext(this)) { + return true; + } + return false; + } /** * Return the cell type. @@ -550,10 +557,7 @@ public final class XSSFCell implements Cell { */ @Override public int getCellType() { - - if (_cell.getF() != null || getSheet().isCellInArrayFormulaContext(this)) { - return CELL_TYPE_FORMULA; - } + if (isFormulaCell()) return CELL_TYPE_FORMULA; return getBaseCellType(true); } @@ -566,7 +570,7 @@ public final class XSSFCell implements Cell { */ @Override public int getCachedFormulaResultType() { - if (_cell.getF() == null) { + if (! isFormulaCell()) { throw new IllegalStateException("Only formula cells have cached results"); }