]> source.dussan.org Git - poi.git/commitdiff
allow HSSFSharedString
authorPJ Fanning <fanningpj@apache.org>
Tue, 12 Jul 2022 09:25:57 +0000 (09:25 +0000)
committerPJ Fanning <fanningpj@apache.org>
Tue, 12 Jul 2022 09:25:57 +0000 (09:25 +0000)
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1902673 13f79535-47bb-0310-9956-ffa450edef68

poi-ooxml/src/main/java/org/apache/poi/xssf/usermodel/XSSFCell.java

index 23e33a249708aa6eb2815cfbf11f691f3c8fc639..0a85c786c70ee89682e11361aef6a1468ef9c2ba 100644 (file)
@@ -354,12 +354,18 @@ public final class XSSFCell extends CellBase {
             if(_cell.getT() == STCellType.INLINE_STR) {
                 //set the 'pre-evaluated result
                 _cell.setV(str.getString());
-            } else {
+            } else if (str instanceof XSSFRichTextString) {
                 _cell.setT(STCellType.S);
                 XSSFRichTextString rt = (XSSFRichTextString)str;
                 rt.setStylesTableReference(_stylesSource);
                 int sRef = _sharedStringSource.addSharedStringItem(rt);
                 _cell.setV(Integer.toString(sRef));
+            } else {
+                _cell.setT(STCellType.S);
+                XSSFRichTextString rt = new XSSFRichTextString(str.getString());
+                rt.setStylesTableReference(_stylesSource);
+                int sRef = _sharedStringSource.addSharedStringItem(rt);
+                _cell.setV(Integer.toString(sRef));
             }
         }
     }