]> source.dussan.org Git - poi.git/commitdiff
Explicitly set the 1900 date system when creating XSSF workbooks, see Bugzilla 47411
authorYegor Kozlov <yegor@apache.org>
Sat, 27 Jun 2009 11:21:26 +0000 (11:21 +0000)
committerYegor Kozlov <yegor@apache.org>
Sat, 27 Jun 2009 11:21:26 +0000 (11:21 +0000)
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@788956 13f79535-47bb-0310-9956-ffa450edef68

src/documentation/content/xdocs/status.xml
src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFWorkbook.java
src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFWorkbook.java

index 35554d1143dbbb6c1b2da7fb7be09dc2a31085a2..dfa706680ca8c4b504e1dde8f239a3bad1758322 100644 (file)
@@ -33,6 +33,7 @@
 
     <changes>
         <release version="3.5-beta7" date="2009-??-??">
+           <action dev="POI-DEVELOPERS" type="fix">47411 - Explicitly set the 1900 date system when creating XSSF workbooks</action>
            <action dev="POI-DEVELOPERS" type="add">47400 - Support fo text extraction of footnotes, endnotes and comments in HWPF</action>
            <action dev="POI-DEVELOPERS" type="fix">47415 - Fixed PageSettingsBlock to allow multiple PLS records</action>
            <action dev="POI-DEVELOPERS" type="fix">47412 - Fixed concurrency issue with EscherProperties.initProps()</action>
index 461fe603940986d90ed8e2c860dd515cdbc89fcf..5d509260e3d749b7a50daba69f7f84215be9c2aa 100644 (file)
@@ -215,6 +215,11 @@ public class XSSFWorkbook extends POIXMLDocument implements Workbook, Iterable<X
      */
     private void onWorkbookCreate() {
         workbook = CTWorkbook.Factory.newInstance();
+
+        // don't EVER use the 1904 date system
+        CTWorkbookPr workbookPr = workbook.addNewWorkbookPr();
+        workbookPr.setDate1904(false);
+
         CTBookViews bvs = workbook.addNewBookViews();
         CTBookView bv = bvs.addNewWorkbookView();
         bv.setActiveTab(0);
index 33de41f84603a55a0245eb49f82b84713c43020f..749b92114bd3c44dbeb109c0f4b89b3a1c7da4de 100644 (file)
@@ -35,6 +35,7 @@ import org.apache.poi.openxml4j.opc.PackagePart;
 import org.apache.poi.openxml4j.opc.PackagingURIHelper;
 import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTSheet;
 import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTWorkbook;
+import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTWorkbookPr;
 
 public final class TestXSSFWorkbook extends BaseTestWorkbook {
 
@@ -49,7 +50,14 @@ public final class TestXSSFWorkbook extends BaseTestWorkbook {
         */
        public void testSaveLoadNew() throws Exception {
                XSSFWorkbook workbook = new XSSFWorkbook();
-               Sheet sheet1 = workbook.createSheet("sheet1");
+
+        //check that the default date system is set to 1900
+        CTWorkbookPr pr = workbook.getCTWorkbook().getWorkbookPr();
+        assertNotNull(pr);
+        assertTrue(pr.isSetDate1904());
+        assertFalse("XSSF must use the 1900 date system", pr.getDate1904());
+
+        Sheet sheet1 = workbook.createSheet("sheet1");
                Sheet sheet2 = workbook.createSheet("sheet2");
                workbook.createSheet("sheet3");