From: Josh Micich Date: Thu, 30 Oct 2008 21:55:50 +0000 (+0000) Subject: Fixed compilation error introduced in r708982 X-Git-Tag: ooxml_20081107~7 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=2b9938194aeb72c5ec3e4f0c98488f99b713a39a;p=poi.git Fixed compilation error introduced in r708982 git-svn-id: https://svn.apache.org/repos/asf/poi/branches/ooxml@709260 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/src/java/org/apache/poi/ss/usermodel/DataFormatter.java b/src/java/org/apache/poi/ss/usermodel/DataFormatter.java index a8f01ca720..2d621eea1b 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); + if (cellType == Cell.CELL_TYPE_FORMULA) { + if (evaluator == null) { + return cell.getCellFormula(); } + cellType = evaluator.evaluateFormulaCell(cell); } - switch (cellType) - { - case Cell.CELL_TYPE_FORMULA : - // should only occur if evaluator is null - return cell.getCellFormula(); - + 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 a42fbc2643..2dbb5715b0 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);