]> source.dussan.org Git - poi.git/commitdiff
use non deprecated method for adding string to shared strings table
authorPJ Fanning <fanningpj@apache.org>
Mon, 18 Dec 2017 20:54:39 +0000 (20:54 +0000)
committerPJ Fanning <fanningpj@apache.org>
Mon, 18 Dec 2017 20:54:39 +0000 (20:54 +0000)
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1818623 13f79535-47bb-0310-9956-ffa450edef68

src/ooxml/java/org/apache/poi/xssf/model/SharedStringsTable.java
src/ooxml/java/org/apache/poi/xssf/streaming/SheetDataWriter.java

index 241d06f63daf6f17720b103bd2320dde2195d49e..8d3d57ef8b0198e9f1a11831096599706a856788 100644 (file)
@@ -193,7 +193,7 @@ public class SharedStringsTable extends POIXMLDocumentPart {
      * @return index the index of added entry
      * @deprecated use <code>addSharedStringItem(RichTextString string)</code> instead
      */
-    @Removal(version = "4.2")
+    @Removal(version = "4.2") //make private in 4.2
     public int addEntry(CTRst st) {
         String s = getKey(st);
         count++;
@@ -278,8 +278,8 @@ public class SharedStringsTable extends POIXMLDocumentPart {
     @Override
     protected void commit() throws IOException {
         PackagePart part = getPackagePart();
-        OutputStream out = part.getOutputStream();
-        writeTo(out);
-        out.close();
+        try (OutputStream out = part.getOutputStream()) {
+            writeTo(out);
+        }
     }
 }
index cae2aee0d14f7495306a2fda1b62f667d3ec072e..f47c93ebf19359289d1035253a641c75d12f8d76 100644 (file)
@@ -280,7 +280,7 @@ public class SheetDataWriter implements Closeable {
             case STRING: {
                 if (_sharedStringSource != null) {
                     XSSFRichTextString rt = new XSSFRichTextString(cell.getStringCellValue());
-                    int sRef = _sharedStringSource.addEntry(rt.getCTRst());
+                    int sRef = _sharedStringSource.addSharedStringItem(rt);
 
                     writeAttribute("t", STCellType.S.toString());
                     _out.write("><v>");