Skip to content

Remove locale from format string to prevent formatting error#644

Merged
PowerKiKi merged 2 commits intoPHPOffice:developfrom
deekthesqueak:LocaleFormatBug
Sep 28, 2018
Merged

Remove locale from format string to prevent formatting error#644
PowerKiKi merged 2 commits intoPHPOffice:developfrom
deekthesqueak:LocaleFormatBug

Conversation

@deekthesqueak
Copy link
Contributor

This is:

- [x] a bugfix

Checklist:

Why this change is needed?

When a formatting string has a locale in it an error can occur when outputting. For example when the format string with a locale such as [$-1010409]#,##0.00;-#,##0.00 appears, a value of 9.98 comes back as $9.98. This is because at https://github.com/PHPOffice/PhpSpreadsheet/blob/1.4.0/src/PhpSpreadsheet/Style/NumberFormat.php#L711 the numberFormat regex will match to the zeros inside the locale ([$-1010409]). Attempts to adjust the numberFormat regex caused regressions in other tests. Adding another step to filter out the locale caused no regression.

@PowerKiKi PowerKiKi merged commit 01501b6 into PHPOffice:develop Sep 28, 2018
@PowerKiKi
Copy link
Member

Thanks !

@deekthesqueak deekthesqueak deleted the LocaleFormatBug branch October 7, 2018 07:08
Dfred pushed a commit to Dfred/PhpSpreadsheet that referenced this pull request Nov 20, 2018
…ce#644)

When a formatting string has a locale in it an error can occur when outputting. For example when the format string with a locale such as `[$-1010409]#,##0.00;-#,##0.00` appears, a value of 9.98 comes back as $9.98. This is because at https://github.com/PHPOffice/PhpSpreadsheet/blob/1.4.0/src/PhpSpreadsheet/Style/NumberFormat.php#L711 the numberFormat regex will match to the zeros inside the locale ([$-1010409]). Attempts to adjust the numberFormat regex caused regressions in other tests. Adding another step to filter out the locale caused no regression.
BlackyTay pushed a commit to BlackyTay/PhpSpreadsheet that referenced this pull request Aug 8, 2025
…ce#644)

When a formatting string has a locale in it an error can occur when outputting. For example when the format string with a locale such as `[$-1010409]#,##0.00;-#,##0.00` appears, a value of 9.98 comes back as $9.98. This is because at https://github.com/PHPOffice/PhpSpreadsheet/blob/1.4.0/src/PhpSpreadsheet/Style/NumberFormat.php#L711 the numberFormat regex will match to the zeros inside the locale ([$-1010409]). Attempts to adjust the numberFormat regex caused regressions in other tests. Adding another step to filter out the locale caused no regression.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants