Handle some discrepancies between the ECMA standard and actual internal number formats used by MS Excel

This commit is contained in:
MarkBaker 2015-08-02 00:40:42 +01:00
parent d7ef6810a4
commit 7c0208bd26
1 changed files with 29 additions and 7 deletions

View File

@ -245,6 +245,28 @@ class NumberFormat extends Supervisor implements \PHPExcel\IComparable
*/ */
private static function fillBuiltInFormatCodes() private static function fillBuiltInFormatCodes()
{ {
// [MS-OI29500: Microsoft Office Implementation Information for ISO/IEC-29500 Standard Compliance]
// 18.8.30. numFmt (Number Format)
//
// The ECMA standard defines built-in format IDs
// 14: "mm-dd-yy"
// 22: "m/d/yy h:mm"
// 37: "#,##0 ;(#,##0)"
// 38: "#,##0 ;[Red](#,##0)"
// 39: "#,##0.00;(#,##0.00)"
// 40: "#,##0.00;[Red](#,##0.00)"
// 47: "mmss.0"
// KOR fmt 55: "yyyy-mm-dd"
// Excel defines built-in format IDs
// 14: "m/d/yyyy"
// 22: "m/d/yyyy h:mm"
// 37: "#,##0_);(#,##0)"
// 38: "#,##0_);[Red](#,##0)"
// 39: "#,##0.00_);(#,##0.00)"
// 40: "#,##0.00_);[Red](#,##0.00)"
// 47: "mm:ss.0"
// KOR fmt 55: "yyyy/mm/dd"
// Built-in format codes // Built-in format codes
if (is_null(self::$builtInFormats)) { if (is_null(self::$builtInFormats)) {
self::$builtInFormats = array(); self::$builtInFormats = array();
@ -261,7 +283,7 @@ class NumberFormat extends Supervisor implements \PHPExcel\IComparable
self::$builtInFormats[11] = '0.00E+00'; self::$builtInFormats[11] = '0.00E+00';
self::$builtInFormats[12] = '# ?/?'; self::$builtInFormats[12] = '# ?/?';
self::$builtInFormats[13] = '# ??/??'; self::$builtInFormats[13] = '# ??/??';
self::$builtInFormats[14] = 'mm-dd-yy'; self::$builtInFormats[14] = 'm/d/yyyy'; // Despite ECMA 'mm-dd-yy';
self::$builtInFormats[15] = 'd-mmm-yy'; self::$builtInFormats[15] = 'd-mmm-yy';
self::$builtInFormats[16] = 'd-mmm'; self::$builtInFormats[16] = 'd-mmm';
self::$builtInFormats[17] = 'mmm-yy'; self::$builtInFormats[17] = 'mmm-yy';
@ -269,17 +291,17 @@ class NumberFormat extends Supervisor implements \PHPExcel\IComparable
self::$builtInFormats[19] = 'h:mm:ss AM/PM'; self::$builtInFormats[19] = 'h:mm:ss AM/PM';
self::$builtInFormats[20] = 'h:mm'; self::$builtInFormats[20] = 'h:mm';
self::$builtInFormats[21] = 'h:mm:ss'; self::$builtInFormats[21] = 'h:mm:ss';
self::$builtInFormats[22] = 'm/d/yy h:mm'; self::$builtInFormats[22] = 'm/d/yyyy h:mm'; // Despite ECMA 'm/d/yy h:mm';
self::$builtInFormats[37] = '#,##0 ;(#,##0)'; self::$builtInFormats[37] = '#,##0_);(#,##0)'; // Despite ECMA '#,##0 ;(#,##0)';
self::$builtInFormats[38] = '#,##0 ;[Red](#,##0)'; self::$builtInFormats[38] = '#,##0_);[Red](#,##0)'; // Despite ECMA '#,##0 ;[Red](#,##0)';
self::$builtInFormats[39] = '#,##0.00;(#,##0.00)'; self::$builtInFormats[39] = '#,##0.00_);(#,##0.00)'; // Despite ECMA '#,##0.00;(#,##0.00)';
self::$builtInFormats[40] = '#,##0.00;[Red](#,##0.00)'; self::$builtInFormats[40] = '#,##0.00_);[Red](#,##0.00)'; // Despite ECMA '#,##0.00;[Red](#,##0.00)';
self::$builtInFormats[44] = '_("$"* #,##0.00_);_("$"* \(#,##0.00\);_("$"* "-"??_);_(@_)'; self::$builtInFormats[44] = '_("$"* #,##0.00_);_("$"* \(#,##0.00\);_("$"* "-"??_);_(@_)';
self::$builtInFormats[45] = 'mm:ss'; self::$builtInFormats[45] = 'mm:ss';
self::$builtInFormats[46] = '[h]:mm:ss'; self::$builtInFormats[46] = '[h]:mm:ss';
self::$builtInFormats[47] = 'mmss.0'; self::$builtInFormats[47] = 'mm:ss.0'; // Despite ECMA 'mmss.0';
self::$builtInFormats[48] = '##0.0E+0'; self::$builtInFormats[48] = '##0.0E+0';
self::$builtInFormats[49] = '@'; self::$builtInFormats[49] = '@';