]> source.dussan.org Git - poi.git/commitdiff
Revert changes from rev. 1513916 as it severly broke writing valid xlsx files
authorDominik Stadler <centic@apache.org>
Tue, 20 Aug 2013 15:03:18 +0000 (15:03 +0000)
committerDominik Stadler <centic@apache.org>
Tue, 20 Aug 2013 15:03:18 +0000 (15:03 +0000)
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1515842 13f79535-47bb-0310-9956-ffa450edef68

src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFSheet.java
src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFWorkbook.java

index c2f379fa89acaffb2143d2868a856e1a187519c1..f494c67122851dcb4b73ea7be4dc5aa9e9f307b1 100644 (file)
@@ -2689,14 +2689,15 @@ public class XSSFSheet extends POIXMLDocumentPart implements Sheet {
     }
 
     protected void write(OutputStream out) throws IOException {
-
         if(worksheet.sizeOfColsArray() == 1) {
-            CTCols col = worksheet.getColsArray(0);
-            if(col.sizeOfColArray() != 0) {
+               CTCols col = worksheet.getColsArray(0);
+            if(col.sizeOfColArray() == 0) {
+               // this is necessary so that we do not write an empty <cols/> item into the sheet-xml in the xlsx-file
+               // Excel complains about a corrupted file if this shows up there!
+                worksheet.setColsArray(null);
+            } else {
                setColWidthAttribute(col);
-            } /*else {
-               remove, see Bug 52233: worksheet.setColsArray(null);
-            }*/
+            }
         }
 
         // Now re-generate our CTHyperlinks, if needed
index 5bb87569144c586ad54d37d3d8676efd61217188..8f583efbc5b511b739104f96ef250e58dd345774 100644 (file)
@@ -462,7 +462,8 @@ public final class TestXSSFWorkbook extends BaseTestWorkbook {
                 sh.getCTWorksheet().getSheetPr().getTabColor().getIndexed());
     }
 
-       public void testColumnWidthPOI52233() throws Exception {
+    // TODO: disabled as the fix for this had severe side-effects
+       public void doNotRuntestColumnWidthPOI52233() throws Exception {
                XSSFWorkbook workbook = new XSSFWorkbook();
                XSSFSheet sheet = workbook.createSheet();
                XSSFRow row = sheet.createRow(0);