From 2a63c7e75ddf7fdaf68a0dfa2d3d7a959576cbb2 Mon Sep 17 00:00:00 2001 From: PJ Fanning Date: Mon, 18 Dec 2017 20:54:39 +0000 Subject: [PATCH] use non deprecated method for adding string to shared strings table git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1818623 13f79535-47bb-0310-9956-ffa450edef68 --- .../org/apache/poi/xssf/model/SharedStringsTable.java | 8 ++++---- .../org/apache/poi/xssf/streaming/SheetDataWriter.java | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/ooxml/java/org/apache/poi/xssf/model/SharedStringsTable.java b/src/ooxml/java/org/apache/poi/xssf/model/SharedStringsTable.java index 241d06f63d..8d3d57ef8b 100644 --- a/src/ooxml/java/org/apache/poi/xssf/model/SharedStringsTable.java +++ b/src/ooxml/java/org/apache/poi/xssf/model/SharedStringsTable.java @@ -193,7 +193,7 @@ public class SharedStringsTable extends POIXMLDocumentPart { * @return index the index of added entry * @deprecated use addSharedStringItem(RichTextString string) 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); + } } } diff --git a/src/ooxml/java/org/apache/poi/xssf/streaming/SheetDataWriter.java b/src/ooxml/java/org/apache/poi/xssf/streaming/SheetDataWriter.java index cae2aee0d1..f47c93ebf1 100644 --- a/src/ooxml/java/org/apache/poi/xssf/streaming/SheetDataWriter.java +++ b/src/ooxml/java/org/apache/poi/xssf/streaming/SheetDataWriter.java @@ -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(">");