diff options
author | Yegor Kozlov <yegor@apache.org> | 2009-08-09 13:08:59 +0000 |
---|---|---|
committer | Yegor Kozlov <yegor@apache.org> | 2009-08-09 13:08:59 +0000 |
commit | 58f32a32b545ae8075fb47f43ce0b5505e167075 (patch) | |
tree | ad5657157cbf446c9ea7585330db8b6dc799c4ac | |
parent | e50f913b437e0ced78cfa2b7d3b79b5bcc9eb260 (diff) | |
download | poi-58f32a32b545ae8075fb47f43ce0b5505e167075.tar.gz poi-58f32a32b545ae8075fb47f43ce0b5505e167075.zip |
removed temporary fix for compatibility with Mac Excel 2008 Sp2
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@802539 13f79535-47bb-0310-9956-ffa450edef68
6 files changed, 8 insertions, 39 deletions
diff --git a/src/documentation/content/xdocs/spreadsheet/index.xml b/src/documentation/content/xdocs/spreadsheet/index.xml index a9f025e4e2..f52d60c3dd 100644 --- a/src/documentation/content/xdocs/spreadsheet/index.xml +++ b/src/documentation/content/xdocs/spreadsheet/index.xml @@ -74,36 +74,5 @@ 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> diff --git a/src/ooxml/java/org/apache/poi/POIXMLDocument.java b/src/ooxml/java/org/apache/poi/POIXMLDocument.java index ace5d01986..1f0d907080 100644 --- a/src/ooxml/java/org/apache/poi/POIXMLDocument.java +++ b/src/ooxml/java/org/apache/poi/POIXMLDocument.java @@ -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"; diff --git a/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFWorkbook.java b/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFWorkbook.java index d08cbc5eea..15ddd8f127 100644 --- a/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFWorkbook.java +++ b/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFWorkbook.java @@ -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){ diff --git a/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFDocument.java b/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFDocument.java index 669bc4429d..8f354c3f50 100644 --- a/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFDocument.java +++ b/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFDocument.java @@ -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); } /** diff --git a/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFWorkbook.java b/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFWorkbook.java index 2df9d8beef..8cccf8122e 100644 --- a/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFWorkbook.java +++ b/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFWorkbook.java @@ -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()); diff --git a/src/ooxml/testcases/org/apache/poi/xwpf/TestXWPFDocument.java b/src/ooxml/testcases/org/apache/poi/xwpf/TestXWPFDocument.java index 881adf34b2..ada54b0d8e 100644 --- a/src/ooxml/testcases/org/apache/poi/xwpf/TestXWPFDocument.java +++ b/src/ooxml/testcases/org/apache/poi/xwpf/TestXWPFDocument.java @@ -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()); } } |