-
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
Formatting general cell #2239
Comments
Can you upload a file that demonstrates this problem? I've used Apache OpenOffice to save a file, but I don't see GENERAL, in any configuration of lower/upper case, |
passe partouts.xls |
I've downloaded your file. I don't see what the problem is. I was able to read it in using PhpSpreadsheet, and write it out (as both xlsx and xls) without seeing any difference between those and the original. What am I missing? |
Did you open it first? Because when you open the file and save it, the problem is (most of the times) gone. $excelFile = \PhpOffice\PhpSpreadsheet\IOFactory::load($filePath);
$sheet = $excelFile->getSheetByName('Blad1');
$array = $sheet->toArray();
echo $array[1][4]; The result should be '21', but I get 'GENERAL' as result. |
I do duplicate that result. Interesting. getValue and getCalculatedValue are returning the correct result, but getFormattedValue and toArray are not. |
See issue PHPOffice#2239. Problem is dealt with at the source, by making sure that Reader Xls checks for use of 'GENERAL' rather than 'General'. There doesn't seem to be a reason to test in other places, or to test for other casing variants.
Fixed in 1.19.0 |
This is:
What is the expected behavior?
Do not format general cells.
What is the current behavior?
In some files, a cell with the format 'General' is formatted.
What are the steps to reproduce?
Some excel files, have named the format 'GENERAL' instead of 'General'. Because the compare in PhpSpreadsheet is case sensitive, it will be formatted. As result, the value is 'GENERAL' instead of the real cell value.
This occurs when the files are created with Apache OpenOffice instead of Microsoft Excel.
Current code [PhpSpreadsheet\Style\NumberFormat\Formatter.php on line 111]:
Could be (working for us):
The same code could be found on PhpSpreadsheet\Style\NumberFormat\Formatter.php on line 168.
There might be some other places where this bug occurs (or maybe also with other formatting options?).
Which versions of PhpSpreadsheet and PHP are affected?
v1.18.0
The text was updated successfully, but these errors were encountered: