diff options
author | Nick Burch <nick@apache.org> | 2008-03-29 16:41:25 +0000 |
---|---|---|
committer | Nick Burch <nick@apache.org> | 2008-03-29 16:41:25 +0000 |
commit | 1684f36a8f87471be7cab1a045e7bda9f0bee427 (patch) | |
tree | e8f301b355a0bf57f0250146b70a543a81d90fb5 /src/java/org/apache/poi/hssf/usermodel/HSSFCell.java | |
parent | 4bdf3c6de2563256b6ba072eb5ba71310d269b5f (diff) | |
download | poi-1684f36a8f87471be7cab1a045e7bda9f0bee427.tar.gz poi-1684f36a8f87471be7cab1a045e7bda9f0bee427.zip |
Merge changes from trunk to the ooxml branch - revisions 634630 to
638000
git-svn-id: https://svn.apache.org/repos/asf/poi/branches/ooxml@642554 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/java/org/apache/poi/hssf/usermodel/HSSFCell.java')
-rw-r--r-- | src/java/org/apache/poi/hssf/usermodel/HSSFCell.java | 43 |
1 files changed, 22 insertions, 21 deletions
diff --git a/src/java/org/apache/poi/hssf/usermodel/HSSFCell.java b/src/java/org/apache/poi/hssf/usermodel/HSSFCell.java index ae8a8253e6..ededf0d648 100644 --- a/src/java/org/apache/poi/hssf/usermodel/HSSFCell.java +++ b/src/java/org/apache/poi/hssf/usermodel/HSSFCell.java @@ -603,29 +603,30 @@ public class HSSFCell implements Cell if (hvalue == null) { setCellType(CELL_TYPE_BLANK, false, row, col, styleIndex); + return; } - else - { - if ((cellType != CELL_TYPE_STRING ) && ( cellType != CELL_TYPE_FORMULA)) - { - setCellType(CELL_TYPE_STRING, false, row, col, styleIndex); - } - int index = 0; - - UnicodeString str = hvalue.getUnicodeString(); -// jmh if (encoding == ENCODING_COMPRESSED_UNICODE) -// jmh { -// jmh str.setCompressedUnicode(); -// jmh } else if (encoding == ENCODING_UTF_16) -// jmh { -// jmh str.setUncompressedUnicode(); -// jmh } - index = book.addSSTString(str); - (( LabelSSTRecord ) record).setSSTIndex(index); - stringValue = hvalue; - stringValue.setWorkbookReferences(book, (( LabelSSTRecord ) record)); - stringValue.setUnicodeString(book.getSSTString(index)); + if (cellType == CELL_TYPE_FORMULA) { + // Set the 'pre-evaluated result' for the formula + // note - formulas do not preserve text formatting. + FormulaRecordAggregate fr = (FormulaRecordAggregate) record; + // must make new sr because fr.getStringRecord() may be null + StringRecord sr = new StringRecord(); + sr.setString(hvalue.getString()); // looses format + fr.setStringRecord(sr); + return; + } + + if (cellType != CELL_TYPE_STRING) { + setCellType(CELL_TYPE_STRING, false, row, col, styleIndex); } + int index = 0; + + UnicodeString str = hvalue.getUnicodeString(); + index = book.addSSTString(str); + (( LabelSSTRecord ) record).setSSTIndex(index); + stringValue = hvalue; + stringValue.setWorkbookReferences(book, (( LabelSSTRecord ) record)); + stringValue.setUnicodeString(book.getSSTString(index)); } public void setCellFormula(String formula) { |