-
Notifications
You must be signed in to change notification settings - Fork 3.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Number format error #1329
Comments
I can confirm I experiment the same bug since I updated the lib. However, I do encounter said bug only when I pass in a float value to To fix this (until you do), I do this (convert float to string):
But I am not sure this is the best way to do it... Well, at least it fixes the bug. |
EDIT: actually it does not fix everything. Now the numbers are converted to strings in Excel, and I can no longer sum them or whatever, and the numberformat I am using has no effect:
|
The only solution is to downgrade to |
We have the same problem here. With 1.10.0 it works without any problems. |
This issue is caused by #1262 In the original code there is a str_replace: // force point as decimal separator in case current locale uses comma
$objWriter->writeElement('v', str_replace(',', '.', $cellValue)); But in the pull request, some code was added before this comma-to-point translation, forcing a ".0" after the value: if (strpos($cellValue, '.') === false) {
$cellValue = $cellValue . '.0';
} Apart from this being very very weird code. The force decimal should be added after converting commas's. |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. |
Fixed by PR #1282 in January 2020. |
This is:
What is the expected behavior?
Write decimal numbers like "1201,23" on a table.
What is the current behavior?
The number is writen like "1201.23.0" and was formated as string
What are the steps to reproduce?
This error occurs only on countries that use "," (comma) as a decimal separator (onlu to wtite a .xlsx file).
When the version 1.10.1 was writen, a decimal problem with a "." (dot) as a separator was solved (at PhpSpreadsheet/Writer/Xlsx/Worksheet.php - line 1146) but at countries that use a "," (comma - like Brazil or some european countries), the decimal number comes with a wrong formatation.
To solve, I had to use the 1.10.0 version on my composer file.
To replicate the bug, set "," (comma) as a decimal separator and "." (dot) as thousand separator on your OS
Please provide a Minimal, Complete, and Verifiable example of code that exhibits the issue without relying on an external Excel file or a web server:
Other error like this:
https://stackoverflow.com/questions/59393839/number-formatting-phpspreadsheet-with-decimals-not-seen-as-numbers-by-the-export
Which versions of PhpSpreadsheet and PHP are affected?
PhpSpreadsheet: 1.10.1
The text was updated successfully, but these errors were encountered: