Merge remote-tracking branch 'origin/master'
# Conflicts: # tests/data/Style/NumberFormat.php
This commit is contained in:
commit
effa5175ed
|
@ -15,7 +15,8 @@ and this project adheres to [Semantic Versioning](https://semver.org).
|
|||
|
||||
### Fixed
|
||||
|
||||
- Stricter-typed comparison testing in COUNTIF() and COUNTIFS() evaluation [Issue #1046](https://github.com/PHPOffice/PhpSpreadsheet/issues/1046)
|
||||
- Fix number format masks containing named colours that were being misinterpreted as date formats; and add support for masks that fully replace the value with a full text string [Issue #1009](https://github.com/PHPOffice/PhpSpreadsheet/issues/1009)
|
||||
- Stricter-typed comparison testing in COUNTIF() and COUNTIFS() evaluation [Issue #1046](https://github.com/PHPOffice/PhpSpreadsheet/issues/1046)
|
||||
- COUPNUM should not return zero when settlement is in the last period - [Issue #1020](https://github.com/PHPOffice/PhpSpreadsheet/issues/1020) and [PR #1021](https://github.com/PHPOffice/PhpSpreadsheet/pull/1021)
|
||||
|
||||
## [1.8.2] - 2019-07-08
|
||||
|
|
|
@ -6,6 +6,17 @@ use PhpOffice\PhpSpreadsheet\Exception as PhpSpreadsheetException;
|
|||
|
||||
class Color extends Supervisor
|
||||
{
|
||||
const NAMED_COLORS = [
|
||||
'Black',
|
||||
'White',
|
||||
'Red',
|
||||
'Green',
|
||||
'Blue',
|
||||
'Yellow',
|
||||
'Magenta',
|
||||
'Cyan',
|
||||
];
|
||||
|
||||
// Colors
|
||||
const COLOR_BLACK = 'FF000000';
|
||||
const COLOR_WHITE = 'FFFFFFFF';
|
||||
|
|
|
@ -660,7 +660,9 @@ class NumberFormat extends Supervisor
|
|||
|
||||
// Save format with color information for later use below
|
||||
$formatColor = $format;
|
||||
|
||||
// Strip colour information
|
||||
$color_regex = '/\[(' . implode('|', Color::NAMED_COLORS) . ')\]/';
|
||||
$format = preg_replace($color_regex, '', $format);
|
||||
// Let's begin inspecting the format and converting the value to a formatted string
|
||||
|
||||
// Check for date/time characters (not inside quotes)
|
||||
|
@ -668,10 +670,9 @@ class NumberFormat extends Supervisor
|
|||
// datetime format
|
||||
self::formatAsDate($value, $format);
|
||||
} else {
|
||||
// Strip color information
|
||||
$color_regex = '/^\\[[a-zA-Z]+\\]/';
|
||||
$format = preg_replace($color_regex, '', $format);
|
||||
if (preg_match('/%$/', $format)) {
|
||||
if (substr($format, 0, 1) === '"' && substr($format, -1, 1) === '"') {
|
||||
$value = substr($format, 1, -1);
|
||||
} elseif (preg_match('/%$/', $format)) {
|
||||
// % number format
|
||||
self::formatAsPercentage($value, $format);
|
||||
} else {
|
||||
|
|
|
@ -38,11 +38,6 @@ return [
|
|||
-70,
|
||||
'#,##0;[Red]-#,##0'
|
||||
],
|
||||
[
|
||||
'70',
|
||||
-70,
|
||||
'#,##0;[Red]#,##0'
|
||||
],
|
||||
[
|
||||
'0.1',
|
||||
0.10000000000000001,
|
||||
|
|
|
@ -77,22 +77,4 @@ return [
|
|||
1.1354166666667,
|
||||
'[h]:mm',
|
||||
],
|
||||
// Percentage
|
||||
[
|
||||
'12%',
|
||||
0.12,
|
||||
'0%',
|
||||
],
|
||||
// Simple color
|
||||
[
|
||||
'12345',
|
||||
12345,
|
||||
'[Green]General',
|
||||
],
|
||||
// Multiple colors
|
||||
[
|
||||
'12345',
|
||||
12345,
|
||||
'[Blue]0;[Red]0',
|
||||
],
|
||||
];
|
||||
|
|
Loading…
Reference in New Issue