]> source.dussan.org Git - poi.git/commitdiff
Ensure that XSSFWorkbooks contain a BookView, some corrupt ones do not contain this...
authorDominik Stadler <centic@apache.org>
Sun, 28 Dec 2014 09:08:58 +0000 (09:08 +0000)
committerDominik Stadler <centic@apache.org>
Sun, 28 Dec 2014 09:08:58 +0000 (09:08 +0000)
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1648158 13f79535-47bb-0310-9956-ffa450edef68

src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFWorkbook.java

index f3efe946638192a5dd212388dd09fa8ccd0095a3..ec23f209bee0a2df251129023d5f9091971c10d5 100644 (file)
@@ -238,6 +238,13 @@ public class XSSFWorkbook extends POIXMLDocument implements Workbook, Iterable<X
         
         // Build a tree of POIXMLDocumentParts, this workbook being the root
         load(XSSFFactory.getInstance());
+        
+        // some broken Workbooks miss this...
+        if(!workbook.isSetBookViews()) {
+            CTBookViews bvs = workbook.addNewBookViews();
+            CTBookView bv = bvs.addNewWorkbookView();
+            bv.setActiveTab(0);
+        }
     }
 
     /**
@@ -261,6 +268,13 @@ public class XSSFWorkbook extends POIXMLDocument implements Workbook, Iterable<X
         
         // Build a tree of POIXMLDocumentParts, this workbook being the root
         load(XSSFFactory.getInstance());
+
+        // some broken Workbooks miss this...
+        if(!workbook.isSetBookViews()) {
+            CTBookViews bvs = workbook.addNewBookViews();
+            CTBookView bv = bvs.addNewWorkbookView();
+            bv.setActiveTab(0);
+        }
     }
 
     /**