From 42bf5e5fc6c6299e7f1b3b7d8e178d359cccfcad Mon Sep 17 00:00:00 2001 From: Nick Burch Date: Sat, 1 Aug 2015 21:34:34 +0000 Subject: [PATCH] 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 --- .../org/apache/poi/xssf/usermodel/XSSFCell.java | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) 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 5c16f05e8..bb57f65c6 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"); }