-
Notifications
You must be signed in to change notification settings - Fork 3.6k
Closed
Description
This is:
- [x] a bug report
- [ ] a feature request
- [ ] **not** a usage question (ask them on https://stackoverflow.com/questions/tagged/phpspreadsheet or https://gitter.im/PHPOffice/PhpSpreadsheet)
What is the expected behavior?
If you want to set the Value explicit to TYPE_Numeric but the value ($pValue) ist "null" the value should be also set to "null".
What is the current behavior?
If a Cell looks like that in the xml-file:
<c r="A1" s="109" t="n" />
the Value for this cell will be set to "0" instead of "null".
What are the steps to reproduce?
If you call setValueExplicit with $pValue = null and $pDataType = DataType::TYPE_NUMERIC the value will be set to "0".
Which versions of PhpSpreadsheet and PHP are affected?
PhpSpeadsheet = 1.18.0 - 2021-05-31
PHP = 7.2.4
Possible solution
Change the line 217 in \src\PhpSpreadsheet\Cell\Cell.php from:
$this->value = 0 + $pValue;to
if(is_null($pValue)){
$this->value = null;
}else{
$this->value = 0 + $pValue;
}If you want you can assigne this to me and i will provide a PR with this fix.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels