aboutsummaryrefslogtreecommitdiffstats
path: root/src/ooxml/java/org/apache
diff options
context:
space:
mode:
authorNick Burch <nick@apache.org>2015-07-31 21:44:56 +0000
committerNick Burch <nick@apache.org>2015-07-31 21:44:56 +0000
commitf150abced1f00e5ff0bfae951e72ba23b50e1000 (patch)
treec61b666e5fb16730f3429d8c20c6bb4d6dba1ee5 /src/ooxml/java/org/apache
parent6a82b45b0df3eeb023d996734103af183f282beb (diff)
downloadpoi-f150abced1f00e5ff0bfae951e72ba23b50e1000.tar.gz
poi-f150abced1f00e5ff0bfae951e72ba23b50e1000.zip
More helpful exception on the wrong cell type
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1693656 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/ooxml/java/org/apache')
-rw-r--r--src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFFormulaEvaluator.java12
1 files changed, 6 insertions, 6 deletions
diff --git a/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFFormulaEvaluator.java b/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFFormulaEvaluator.java
index e3cba3caf7..6f2390b3ae 100644
--- a/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFFormulaEvaluator.java
+++ b/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFFormulaEvaluator.java
@@ -153,7 +153,7 @@ public class XSSFFormulaEvaluator implements FormulaEvaluator, WorkbookEvaluator
* of the old formula.
* Else if cell does not contain formula, this method leaves
* the cell unchanged.
- * Note that the same instance of HSSFCell is returned to
+ * Note that the same instance of XSSFCell is returned to
* allow chained calls like:
* <pre>
* int evaluatedCellType = evaluator.evaluateInCell(cell).getCellType();
@@ -164,16 +164,16 @@ public class XSSFFormulaEvaluator implements FormulaEvaluator, WorkbookEvaluator
* @param cell
*/
public XSSFCell evaluateInCell(Cell cell) {
- if (cell == null) {
- return null;
- }
- XSSFCell result = (XSSFCell) cell;
+ doEvaluateInCell(cell);
+ return (XSSFCell)cell;
+ }
+ protected void doEvaluateInCell(Cell cell) {
+ if (cell == null) return;
if (cell.getCellType() == XSSFCell.CELL_TYPE_FORMULA) {
CellValue cv = evaluateFormulaCellValue(cell);
setCellType(cell, cv); // cell will no longer be a formula cell
setCellValue(cell, cv);
}
- return result;
}
private static void setCellType(Cell cell, CellValue cv) {
int cellType = cv.getCellType();