This explains the changes that needs to be done for displaying the dates in different formats.
Excel converts Date to Julean date(Integer).
The Julean date(integer) stored inside Excel sheet can be mapped to various date patterns for display.
The following steps be done programmatically or manually.
Extract the excel document(zipped).
Step1:
Open styles.xml:
Step 1A:
If “numFmts” node exists then add a new “numFmt” node with ur date pattern mapped to “formatCode” attribute,with a unique id (mapped to “numFmtId”) ,else add a new “numFmts” node with “numFmt” as child nodes (as shown below).
For example:
<styleSheet xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/5/main">
<numFmts count="8">
<numFmt numFmtId="1" formatCode="[$-409]dddd\,\ mmmm\ dd\,\ yyyy"/>
<numFmt numFmtId="2" formatCode="m/d/yy;@"/>
<numFmt numFmtId="3" formatCode="yyyy/d/m;@"/>
<numFmt numFmtId="4" formatCode="mmm/yy/dd;@"/>
<numFmt numFmtId="5" formatCode="yyyy/d/m;@"/>
<numFmt numFmtId="6" formatCode="yyyy;@"/>
<numFmt numFmtId="7" formatCode="mmm;@"/>
<numFmt numFmtId="8" formatCode="dd;@"/>
. . . .
. . . .
</numFmts>
<fonts count="1">. . . . . . .
. . . . . .
. . . . . .
. . . . .
</styleSheet>
Note: Define ur own date formats(formatCode) and check with them.
Here are some documented patterns from ECMA doc.
Step 1B:
Map the datepattern to the xf node(child nodes of cellXfs).
Map the desired date pattern id (numFmtId) to the format node(xf)
<styleSheet xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/5/main">
<numFmts count="8">
<numFmt numFmtId="164" formatCode="[$-409]dddd\,\ mmmm\ dd\,\ yyyy"/>
<numFmt numFmtId="165" formatCode="m/d/yy;@"/>
<numFmt numFmtId="166" formatCode="yyyy/d/m;@"/>
<numFmt numFmtId="167" formatCode="mmm/yy/dd;@"/>
<numFmt numFmtId="168" formatCode="yyyy/d/m;@"/>
<numFmt numFmtId="169" formatCode="yyyy;@"/>
<numFmt numFmtId="170" formatCode="mmm;@"/>
<numFmt numFmtId="171" formatCode="dd;@"/>
</numFmts>
<fonts count="1">. . . . . . .
. . . . . .
. . . . . .
. . . . .
<cellXfs count="3">
<xf numFmtId="0" fontId="0" fillId="0" borderId="0" xfId="0"/>
<xf numFmtId="1" />
<xf numFmtId="2" />
<xf numFmtId="3" />
</cellXfs>
</styleSheet>
Remember the node index number for the styleformat node(“xf”) we mapped –in our case it is the second node(node index number: 2).
Save the changes made to styles.xml ,so far.
Step2:
Open Sheet1.xml with the converted Julean date integer value.
Map the style attribute(“s”) of it to the node index number of “xf” inside “styles.xml” (in our case: from step 1B ,it is 2).
For example:
In ur sheet1.xml
<row r="2" spans="1:8">
<c r="A2" s="2">
<v>36526</v>
</c>
....
….
36526 à is the converted juleandate value
s="2" à refers to the second “xf” node in styles.xml
Changing the value of “s” to 3 or 4... will change the format of date displayed.
Now zip the xml files to form the excel sheet to see the formatted dates.
Hope this helps.