diff options
Diffstat (limited to 'src/java/org/apache/poi/hssf/usermodel/HSSFSheet.java')
-rw-r--r-- | src/java/org/apache/poi/hssf/usermodel/HSSFSheet.java | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/src/java/org/apache/poi/hssf/usermodel/HSSFSheet.java b/src/java/org/apache/poi/hssf/usermodel/HSSFSheet.java index 86646286f0..86336034df 100644 --- a/src/java/org/apache/poi/hssf/usermodel/HSSFSheet.java +++ b/src/java/org/apache/poi/hssf/usermodel/HSSFSheet.java @@ -1699,9 +1699,12 @@ public final class HSSFSheet implements org.apache.poi.ss.usermodel.Sheet { } HSSFCellStyle style = cell.getCellStyle(); + int cellType = cell.getCellType(); + if(cellType == HSSFCell.CELL_TYPE_FORMULA) cellType = cell.getCachedFormulaResultType(); + HSSFFont font = wb.getFontAt(style.getFontIndex()); - if (cell.getCellType() == HSSFCell.CELL_TYPE_STRING) { + if (cellType == HSSFCell.CELL_TYPE_STRING) { HSSFRichTextString rt = cell.getRichStringCellValue(); String[] lines = rt.getString().split("\\n"); for (int i = 0; i < lines.length; i++) { @@ -1739,8 +1742,9 @@ public final class HSSFSheet implements org.apache.poi.ss.usermodel.Sheet { } } else { String sval = null; - if (cell.getCellType() == HSSFCell.CELL_TYPE_NUMERIC) { - String format = style.getDataFormatString().replaceAll("\"", ""); + if (cellType == HSSFCell.CELL_TYPE_NUMERIC) { + String dfmt = style.getDataFormatString(); + String format = dfmt == null ? null : dfmt.replaceAll("\"", ""); double value = cell.getNumericCellValue(); try { NumberFormat fmt; @@ -1754,7 +1758,7 @@ public final class HSSFSheet implements org.apache.poi.ss.usermodel.Sheet { } catch (Exception e) { sval = "" + value; } - } else if (cell.getCellType() == HSSFCell.CELL_TYPE_BOOLEAN) { + } else if (cellType == HSSFCell.CELL_TYPE_BOOLEAN) { sval = String.valueOf(cell.getBooleanCellValue()); } if(sval != null) { |