From b79412c217559ec7bfcc3dcb7371dd297c447e87 Mon Sep 17 00:00:00 2001 From: Josh Micich Date: Thu, 30 Oct 2008 21:55:50 +0000 Subject: [PATCH] Fixed compilation error introduced in r708982 git-svn-id: https://svn.apache.org/repos/asf/poi/branches/ooxml@709260 13f79535-47bb-0310-9956-ffa450edef68 --- .../poi/ss/usermodel/DataFormatter.java | 24 +++++++------------ .../org/apache/poi/ss/usermodel/Cell.java | 7 ++++++ 2 files changed, 15 insertions(+), 16 deletions(-) diff --git a/src/java/org/apache/poi/ss/usermodel/DataFormatter.java b/src/java/org/apache/poi/ss/usermodel/DataFormatter.java index a8f01ca72..2d621eea1 100755 --- a/src/java/org/apache/poi/ss/usermodel/DataFormatter.java +++ b/src/java/org/apache/poi/ss/usermodel/DataFormatter.java @@ -63,7 +63,7 @@ import java.text.*; * @author James May (james dot may at fmr dot com) * */ -public class DataFormatter { +public final class DataFormatter { /** Pattern to find a number format: "0" or "#" */ private static final Pattern numPattern = Pattern.compile("[0#]+"); @@ -469,28 +469,20 @@ public class DataFormatter { * @param evaluator The FormulaEvaluator (can be null) * @return a string value of the cell */ - public String formatCellValue(Cell cell, - FormulaEvaluator evaluator) throws IllegalArgumentException { + public String formatCellValue(Cell cell, FormulaEvaluator evaluator) { if (cell == null) { return ""; } int cellType = cell.getCellType(); - if (evaluator != null && cellType == Cell.CELL_TYPE_FORMULA) { - try { - cellType = evaluator.evaluateFormulaCell(cell); - } catch (RuntimeException e) { - throw new RuntimeException("Did you forget to set the current" + - " row on the FormulaEvaluator?", e); - } - } - switch (cellType) - { - case Cell.CELL_TYPE_FORMULA : - // should only occur if evaluator is null + if (cellType == Cell.CELL_TYPE_FORMULA) { + if (evaluator == null) { return cell.getCellFormula(); - + } + cellType = evaluator.evaluateFormulaCell(cell); + } + switch (cellType) { case Cell.CELL_TYPE_NUMERIC : if (DateUtil.isCellDateFormatted(cell)) { diff --git a/src/ooxml/interfaces-jdk14/org/apache/poi/ss/usermodel/Cell.java b/src/ooxml/interfaces-jdk14/org/apache/poi/ss/usermodel/Cell.java index a42fbc264..2dbb5715b 100644 --- a/src/ooxml/interfaces-jdk14/org/apache/poi/ss/usermodel/Cell.java +++ b/src/ooxml/interfaces-jdk14/org/apache/poi/ss/usermodel/Cell.java @@ -17,6 +17,8 @@ package org.apache.poi.ss.usermodel; +import java.util.Date; + import org.apache.poi.hssf.usermodel.HSSFCellStyle; import org.apache.poi.hssf.usermodel.HSSFRichTextString; import org.apache.poi.hssf.usermodel.HSSFSheet; @@ -98,6 +100,11 @@ public interface Cell { boolean getBooleanCellValue(); double getNumericCellValue(); + /** + * get the value of the cell as a date. For strings we throw an exception. + * For blank cells we return a null. + */ + Date getDateCellValue(); HSSFRichTextString getRichStringCellValue(); void setCellType(int cellType);