Substitute a literal dot inside quotes within number format masks to prevent it being mistaken for a decimal separator (#1830)
* Substitute a literal dot inside quotes within number format masks to prevent it being mistaken for a decimal separator
This commit is contained in:
parent
2fac9ee2f7
commit
b068639513
|
|
@ -34,6 +34,7 @@ and this project adheres to [Semantic Versioning](https://semver.org).
|
|||
|
||||
### Fixed
|
||||
|
||||
- Fix problem resulting from literal dot inside quotes in number format masks. [PR #1830](https://github.com/PHPOffice/PhpSpreadsheet/pull/1830)
|
||||
- Resolve Google Sheets Xlsx charts issue. Google Sheets uses oneCellAnchor positioning and does not include *Cache values in the exported Xlsx. [PR #1761](https://github.com/PHPOffice/PhpSpreadsheet/pull/1761)
|
||||
- Fix for Xlsx Chart axis titles mapping to correct X or Y axis label when only one is present. [PR #1760](https://github.com/PHPOffice/PhpSpreadsheet/pull/1760)
|
||||
- Fix For Null Exception on ODS Read of Page Settings. [#1772](https://github.com/PHPOffice/PhpSpreadsheet/issues/1772)
|
||||
|
|
|
|||
|
|
@ -833,6 +833,14 @@ class NumberFormat extends Supervisor
|
|||
return $value;
|
||||
}
|
||||
|
||||
$format = preg_replace_callback(
|
||||
'/(["])(?:(?=(\\\\?))\\2.)*?\\1/u',
|
||||
function ($matches) {
|
||||
return str_replace('.', chr(0x00), $matches[0]);
|
||||
},
|
||||
$format
|
||||
);
|
||||
|
||||
// Convert any other escaped characters to quoted strings, e.g. (\T to "T")
|
||||
$format = preg_replace('/(\\\(((.)(?!((AM\/PM)|(A\/P))))|([^ ])))(?=(?:[^"]|"[^"]*")*$)/u', '"${2}"', $format);
|
||||
|
||||
|
|
@ -868,6 +876,8 @@ class NumberFormat extends Supervisor
|
|||
$value = $writerInstance->$function($value, $colors);
|
||||
}
|
||||
|
||||
$value = str_replace(chr(0x00), '.', $value);
|
||||
|
||||
return $value;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -88,6 +88,26 @@ return [
|
|||
12345.678900000001,
|
||||
'#,##0.000',
|
||||
],
|
||||
[
|
||||
'12.34 kg',
|
||||
12.34,
|
||||
'0.00 "kg"',
|
||||
],
|
||||
[
|
||||
'kg 12.34',
|
||||
12.34,
|
||||
'"kg" 0.00',
|
||||
],
|
||||
[
|
||||
'12.34 kg.',
|
||||
12.34,
|
||||
'0.00 "kg."',
|
||||
],
|
||||
[
|
||||
'kg. 12.34',
|
||||
12.34,
|
||||
'"kg." 0.00',
|
||||
],
|
||||
[
|
||||
'£ 12,345.68',
|
||||
12345.678900000001,
|
||||
|
|
|
|||
Loading…
Reference in New Issue