]> source.dussan.org Git - poi.git/commitdiff
removed temporary fix for compatibility with Mac Excel 2008 Sp2
authorYegor Kozlov <yegor@apache.org>
Sun, 9 Aug 2009 13:08:59 +0000 (13:08 +0000)
committerYegor Kozlov <yegor@apache.org>
Sun, 9 Aug 2009 13:08:59 +0000 (13:08 +0000)
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@802539 13f79535-47bb-0310-9956-ffa450edef68

src/documentation/content/xdocs/spreadsheet/index.xml
src/ooxml/java/org/apache/poi/POIXMLDocument.java
src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFWorkbook.java
src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFDocument.java
src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFWorkbook.java
src/ooxml/testcases/org/apache/poi/xwpf/TestXWPFDocument.java

index a9f025e4e2e90196f1a38155c522c693b258afa6..f52d60c3dd72414a21091398721dcbd63f41df07 100644 (file)
         older HSSF supported (.xls) binary files.
             </p>
         </section>
-        <section>
-          <title>Compatibility of POI-generated .xlsx files with MS Office 2008 for Mac SP2</title>
-          <p>
-            Office 2008 for Mac SP2 version 12.2.0 introduced a serious bug causing some Open XML files to fail to open. 
-            This bug is affecting Open XML files from a variety of sources including the Apache POI project. 
-            The Apache POI project adjusted the XSSF module to produce "MS-compatible OOXML" by setting the Application extended property to "Microsoft Excel". This will allow users to produce OOXML documents that will work with Office 2008 for Mac SP2. 
-            Please see <link href="https://issues.apache.org/bugzilla/show_bug.cgi?id=47559">Bugzilla 47559</link> for more information.
-          </p>
-          <p>
-            Users are advised to patch existing .xlsx files by the following code:
-          </p>
-          <source>
-  XSSFWorkbook wb = new XSSFWorkbook(path);
-
-  POIXMLProperties.ExtendedProperties ext = wb.getProperties().getExtendedProperties();
-  expProps.getUnderlyingProperties().setApplication("Microsoft Excel");
-
-  FileOutputStream out = new FileOutputStream(path);
-  wb.write(out);
-  out.close(); 
-        </source>  
-        <p>To unset the Application property use the following code:</p>
-        <source>  
-  POIXMLProperties.ExtendedProperties ext = workbook.getProperties().getExtendedProperties();
-  expProps.getUnderlyingProperties().unsetApplication();
-        </source>  
-          <warning>
-            This is an effective workaround for a short-term bug which is likely to be removed in future versions of POI, 
-            when Microsoft returns to compliance with the standard. The proper value for Apache POI created documents would to be "Apache POI" and not "Microsoft Excel".  
-        </warning>
-        </section>
     </body>
 </document>
index ace5d01986d22cb9e18522a659b3661f94836b4a..1f0d907080c9efb97013d0105f361a142beaf0f5 100644 (file)
@@ -28,6 +28,7 @@ import org.apache.poi.openxml4j.exceptions.OpenXML4JException;
 import org.apache.poi.openxml4j.opc.*;
 
 public abstract class POIXMLDocument extends POIXMLDocumentPart{
+    public static final String DOCUMENT_CREATOR = "Apache POI";
 
     public static final String CORE_PROPERTIES_REL_TYPE = "http://schemas.openxmlformats.org/package/2006/relationships/metadata/core-properties";
     public static final String EXTENDED_PROPERTIES_REL_TYPE = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/extended-properties";
index d08cbc5eea76225ae2c36d95a7f65d594065b38c..15ddd8f1270f951cc43a2322e19c305e06751672 100644 (file)
@@ -229,9 +229,8 @@ public class XSSFWorkbook extends POIXMLDocument implements Workbook, Iterable<X
         bv.setActiveTab(0);
         workbook.addNewSheets();
 
-        //required by Excel 2008 Mac sp2, see Bugzilla #47559
         POIXMLProperties.ExtendedProperties expProps = getProperties().getExtendedProperties();
-        expProps.getUnderlyingProperties().setApplication("Microsoft Excel");
+        expProps.getUnderlyingProperties().setApplication(DOCUMENT_CREATOR);
 
         sharedStringSource = (SharedStringsTable)createRelationship(XSSFRelation.SHARED_STRINGS, XSSFFactory.getInstance());
         stylesSource = (StylesTable)createRelationship(XSSFRelation.STYLES, XSSFFactory.getInstance());
@@ -253,7 +252,7 @@ public class XSSFWorkbook extends POIXMLDocument implements Workbook, Iterable<X
             // Create main document part
             pkg.createPart(corePartName, XSSFRelation.WORKBOOK.getContentType());
 
-            pkg.getPackageProperties().setCreatorProperty("Apache POI");
+            pkg.getPackageProperties().setCreatorProperty(DOCUMENT_CREATOR);
 
             return pkg;
         } catch (Exception e){
index 669bc4429d6e804fb14c3ae6989a9ed7fe22931a..8f354c3f501ed57a0bef101df7f77aca264e2bd3 100644 (file)
@@ -169,7 +169,7 @@ public class XWPFDocument extends POIXMLDocument {
             // Create main document part
             pkg.createPart(corePartName, XWPFRelation.DOCUMENT.getContentType());
 
-            pkg.getPackageProperties().setCreatorProperty("Apache POI");
+            pkg.getPackageProperties().setCreatorProperty(DOCUMENT_CREATOR);
 
             return pkg;
         } catch (Exception e){
@@ -190,7 +190,7 @@ public class XWPFDocument extends POIXMLDocument {
         ctDocument.addNewBody();
 
         POIXMLProperties.ExtendedProperties expProps = getProperties().getExtendedProperties();
-        expProps.getUnderlyingProperties().setApplication("Microsoft Office Word");
+        expProps.getUnderlyingProperties().setApplication(DOCUMENT_CREATOR);
     }
 
     /**
index 2df9d8beef4f1b84a5e19cf7d513d5199cf4bb4b..8cccf8122e0e4ae6c3bdb0109f0057a69c49e451 100644 (file)
@@ -261,7 +261,7 @@ public final class TestXSSFWorkbook extends BaseTestWorkbook {
         POIXMLProperties props = workbook.getProperties();
         assertNotNull(props);
         //the Application property must be set for new workbooks, see Bugzilla #47559
-        assertEquals("Microsoft Excel", props.getExtendedProperties().getUnderlyingProperties().getApplication());
+        assertEquals("Apache POI", props.getExtendedProperties().getUnderlyingProperties().getApplication());
 
         PackagePropertiesPart opcProps = props.getCoreProperties().getUnderlyingProperties();
         assertNotNull(opcProps);
@@ -271,7 +271,7 @@ public final class TestXSSFWorkbook extends BaseTestWorkbook {
         opcProps.setCreatorProperty("poi-dev@poi.apache.org");
 
         workbook = XSSFTestDataSamples.writeOutAndReadBack(workbook);
-        assertEquals("Microsoft Excel", workbook.getProperties().getExtendedProperties().getUnderlyingProperties().getApplication());
+        assertEquals("Apache POI", workbook.getProperties().getExtendedProperties().getUnderlyingProperties().getApplication());
         opcProps = workbook.getProperties().getCoreProperties().getUnderlyingProperties();
         assertEquals("Testing Bugzilla #47460", opcProps.getTitleProperty().getValue());
         assertEquals("poi-dev@poi.apache.org", opcProps.getCreatorProperty().getValue());
index 881adf34b2d6ea86450318148f93b1f4630b1723..ada54b0d8ea5a663417ab9c444dac9f01da83788 100644 (file)
@@ -125,7 +125,7 @@ public class TestXWPFDocument extends TestCase {
         XWPFDocument doc = new XWPFDocument();
         POIXMLProperties props = doc.getProperties();
         assertNotNull(props);
-        assertEquals("Microsoft Office Word", props.getExtendedProperties().getUnderlyingProperties().getApplication());
+        assertEquals("Apache POI", props.getExtendedProperties().getUnderlyingProperties().getApplication());
     }
 
 }