]> source.dussan.org Git - poi.git/commitdiff
Fix some IntelliJ warnings
authorDominik Stadler <centic@apache.org>
Fri, 16 Jun 2017 11:35:31 +0000 (11:35 +0000)
committerDominik Stadler <centic@apache.org>
Fri, 16 Jun 2017 11:35:31 +0000 (11:35 +0000)
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1798913 13f79535-47bb-0310-9956-ffa450edef68

src/ooxml/java/org/apache/poi/xssf/streaming/SXSSFWorkbook.java
src/ooxml/testcases/org/apache/poi/xssf/streaming/TestSXSSFWorkbook.java

index 15b2830ac3e892a8043e845f5c5b4da5659d44ea..be5b7ea4ee6ad4bdcb9572358e1ffa6211f3a035 100644 (file)
@@ -57,6 +57,7 @@ import org.apache.poi.util.POILogger;
 import org.apache.poi.util.Removal;
 import org.apache.poi.util.TempFile;
 import org.apache.poi.xssf.model.SharedStringsTable;
+import org.apache.poi.xssf.usermodel.XSSFChartSheet;
 import org.apache.poi.xssf.usermodel.XSSFSheet;
 import org.apache.poi.xssf.usermodel.XSSFWorkbook;
 
@@ -382,7 +383,8 @@ public class SXSSFWorkbook implements Workbook {
                     zos.putNextEntry(new ZipEntry(ze.getName()));
                     InputStream is = zipEntrySource.getInputStream(ze);
                     XSSFSheet xSheet=getSheetFromZipEntryName(ze.getName());
-                    if(xSheet!=null) {
+                    // See bug 56557, we should not inject data into the special ChartSheets
+                    if(xSheet!=null && !(xSheet instanceof XSSFChartSheet)) {
                         SXSSFSheet sxSheet=getSXSSFSheet(xSheet);
                         InputStream xis = sxSheet.getWorksheetXMLInputStream();
                         try {
index 2b546daabd03252ad0bb641ad1693544169386c2..2a4653173f0ccd08bb093955923fa421969fd61c 100644 (file)
@@ -577,4 +577,25 @@ public final class TestSXSSFWorkbook extends BaseTestXWorkbook {
         assertEquals(true, s.getRow(0).getCell(0).getBooleanCellValue());
         assertEquals("Test Row 9", s.getRow(9).getCell(2).getStringCellValue());
     }
+
+    @Test
+    public void test56557() throws IOException, InvalidFormatException {
+        Workbook wb = WorkbookFactory.create(XSSFTestDataSamples.getSampleFile("56557.xlsx"));
+
+        // Using streaming XSSFWorkbook makes the output file invalid
+        wb = new SXSSFWorkbook(((XSSFWorkbook) wb));
+
+        Workbook wbBack = XSSFTestDataSamples.writeOutAndReadBack(wb);
+        assertNotNull(wbBack);
+        wbBack.close();
+
+        /*FileOutputStream out = new FileOutputStream("C:/temp/out.xlsx");
+        try {
+            wb.write(out);
+        } finally {
+            out.close();
+        }*/
+
+        wb.close();
+    }
 }