poi-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From n...@apache.org
Subject svn commit: r1720411 - in /poi/trunk: src/java/org/apache/poi/POIDocument.java src/ooxml/java/org/apache/poi/POIXMLDocument.java src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFBugs.java test-data/spreadsheet/58731.xlsx
Date Wed, 16 Dec 2015 18:15:32 GMT
Author: nick
Date: Wed Dec 16 18:15:31 2015
New Revision: 1720411

URL: http://svn.apache.org/viewvc?rev=1720411&view=rev
Log:
Unit test for #58731 - not reproduced, and some javadocs

Added:
    poi/trunk/test-data/spreadsheet/58731.xlsx   (with props)
Modified:
    poi/trunk/src/java/org/apache/poi/POIDocument.java
    poi/trunk/src/ooxml/java/org/apache/poi/POIXMLDocument.java
    poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFBugs.java

Modified: poi/trunk/src/java/org/apache/poi/POIDocument.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/POIDocument.java?rev=1720411&r1=1720410&r2=1720411&view=diff
==============================================================================
--- poi/trunk/src/java/org/apache/poi/POIDocument.java (original)
+++ poi/trunk/src/java/org/apache/poi/POIDocument.java Wed Dec 16 18:15:31 2015
@@ -19,6 +19,7 @@ package org.apache.poi;
 
 import java.io.ByteArrayInputStream;
 import java.io.ByteArrayOutputStream;
+import java.io.File;
 import java.io.IOException;
 import java.io.InputStream;
 import java.io.OutputStream;
@@ -301,6 +302,10 @@ public abstract class POIDocument {
      * Writes the document out to the specified output stream. The
      * stream is not closed as part of this operation.
      * 
+     * Note - if the Document was opened from a {@link File} rather
+     *  than an {@link InputStream}, you <b>must</b> write out to
+     *  a different file, overwriting via an OutputStream isn't possible.
+     * 
      * @param out The stream to write to.
      * 
      * @throws IOException thrown on errors writing to the stream

Modified: poi/trunk/src/ooxml/java/org/apache/poi/POIXMLDocument.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/POIXMLDocument.java?rev=1720411&r1=1720410&r2=1720411&view=diff
==============================================================================
--- poi/trunk/src/ooxml/java/org/apache/poi/POIXMLDocument.java (original)
+++ poi/trunk/src/ooxml/java/org/apache/poi/POIXMLDocument.java Wed Dec 16 18:15:31 2015
@@ -17,6 +17,7 @@
 package org.apache.poi;
 
 import java.io.Closeable;
+import java.io.File;
 import java.io.IOException;
 import java.io.InputStream;
 import java.io.OutputStream;
@@ -196,6 +197,10 @@ public abstract class POIXMLDocument ext
     /**
      * Write out this document to an Outputstream.
      *
+     * Note - if the Document was opened from a {@link File} rather
+     *  than an {@link InputStream}, you <b>must</b> write out to
+     *  a different file, overwriting via an OutputStream isn't possible.
+     * 
      * @param stream - the java OutputStream you wish to write the file to
      *
      * @exception IOException if anything can't be written.

Modified: poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFBugs.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFBugs.java?rev=1720411&r1=1720410&r2=1720411&view=diff
==============================================================================
--- poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFBugs.java (original)
+++ poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFBugs.java Wed Dec
16 18:15:31 2015
@@ -2850,4 +2850,35 @@ public final class TestXSSFBugs extends
         assertNotNull(wbBack);
         wbBack.close();
     }
+    
+    public void test58731() throws Exception {
+        Workbook wb = XSSFTestDataSamples.openSampleWorkbook("58731.xlsx");
+        Sheet sheet = wb.createSheet("Java Books");
+        
+        Object[][] bookData = {
+                {"Head First Java", "Kathy Serria", 79},
+                {"Effective Java", "Joshua Bloch", 36},
+                {"Clean Code", "Robert martin", 42},
+                {"Thinking in Java", "Bruce Eckel", 35},
+        };
+ 
+        int rowCount = 0;
+        for (Object[] aBook : bookData) {
+            Row row = sheet.createRow(++rowCount);
+             
+            int columnCount = 0;
+            for (Object field : aBook) {
+                Cell cell = row.createCell(++columnCount);
+                if (field instanceof String) {
+                    cell.setCellValue((String) field);
+                } else if (field instanceof Integer) {
+                    cell.setCellValue((Integer) field);
+                }
+            }
+        }
+        
+        Workbook wb2 = XSSFTestDataSamples.writeOutAndReadBack(wb);
+        sheet = wb.getSheet("Java Books");
+        assertEquals(bookData[0][0], sheet.getRow(0).getCell(0).getStringCellValue());
+    }
 }

Added: poi/trunk/test-data/spreadsheet/58731.xlsx
URL: http://svn.apache.org/viewvc/poi/trunk/test-data/spreadsheet/58731.xlsx?rev=1720411&view=auto
==============================================================================
Binary file - no diff available.

Propchange: poi/trunk/test-data/spreadsheet/58731.xlsx
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@poi.apache.org
For additional commands, e-mail: commits-help@poi.apache.org


Mime
View raw message