| 1 |
<?php |
| 2 |
|
| 3 |
namespace TablePress\PhpOffice\PhpSpreadsheet\Reader\Xml\Style; |
| 4 |
|
| 5 |
use SimpleXMLElement; |
| 6 |
|
| 7 |
class NumberFormat extends StyleBase |
| 8 |
{ |
| 9 |
/** @return mixed[] */ |
| 10 |
public function parseStyle(SimpleXMLElement $styleAttributes): array |
| 11 |
{ |
| 12 |
$style = []; |
| 13 |
|
| 14 |
$fromFormats = ['\-', '\ ']; |
| 15 |
$toFormats = ['-', ' ']; |
| 16 |
|
| 17 |
foreach ($styleAttributes as $styleAttributeKey => $styleAttributeValue) { |
| 18 |
$styleAttributeValue = str_replace($fromFormats, $toFormats, (string) $styleAttributeValue); |
| 19 |
|
| 20 |
switch ($styleAttributeValue) { |
| 21 |
case 'Short Date': |
| 22 |
$styleAttributeValue = 'dd/mm/yyyy'; |
| 23 |
|
| 24 |
break; |
| 25 |
} |
| 26 |
|
| 27 |
if ($styleAttributeValue > '') { |
| 28 |
$style['numberFormat']['formatCode'] = $styleAttributeValue; |
| 29 |
} |
| 30 |
} |
| 31 |
|
| 32 |
return $style; |
| 33 |
} |
| 34 |
} |
| 35 |
|