Resolution for [#Issue 1972](https://github.com/PHPOffice/PhpSpreadsheet/issues/1972) (#1978)
* Resolution for [#Issue 1972](https://github.com/PHPOffice/PhpSpreadsheet/issues/1972) where format masks with a leading and trailing quote were always treated as literal strings, even when they masks containing quoted characters. Also resolves issue with colour name case-sensitivity
This commit is contained in:
parent
17af13281b
commit
0c403efe60
|
|
@ -26,6 +26,7 @@ and this project adheres to [Semantic Versioning](https://semver.org).
|
||||||
|
|
||||||
### Fixed
|
### Fixed
|
||||||
|
|
||||||
|
- Fixed issue with quoted strings in number format mask rendered with toFormattedString() [Issue 1972#](https://github.com/PHPOffice/PhpSpreadsheet/issues/1972) [PR #1978](https://github.com/PHPOffice/PhpSpreadsheet/pull/1978)
|
||||||
- Fixed issue with percentage formats in number format mask rendered with toFormattedString() [Issue 1929#](https://github.com/PHPOffice/PhpSpreadsheet/issues/1929) [PR #1928](https://github.com/PHPOffice/PhpSpreadsheet/pull/1928)
|
- Fixed issue with percentage formats in number format mask rendered with toFormattedString() [Issue 1929#](https://github.com/PHPOffice/PhpSpreadsheet/issues/1929) [PR #1928](https://github.com/PHPOffice/PhpSpreadsheet/pull/1928)
|
||||||
- Fixed issue with _ spacing character in number format mask corrupting output from toFormattedString() [Issue 1924#](https://github.com/PHPOffice/PhpSpreadsheet/issues/1924) [PR #1927](https://github.com/PHPOffice/PhpSpreadsheet/pull/1927)
|
- Fixed issue with _ spacing character in number format mask corrupting output from toFormattedString() [Issue 1924#](https://github.com/PHPOffice/PhpSpreadsheet/issues/1924) [PR #1927](https://github.com/PHPOffice/PhpSpreadsheet/pull/1927)
|
||||||
- Fix for [Issue #1887](https://github.com/PHPOffice/PhpSpreadsheet/issues/1887) - Lose Track of Selected Cells After Save
|
- Fix for [Issue #1887](https://github.com/PHPOffice/PhpSpreadsheet/issues/1887) - Lose Track of Selected Cells After Save
|
||||||
|
|
|
||||||
|
|
@ -43,7 +43,7 @@ class Formatter
|
||||||
// 3 sections: [POSITIVE/TEXT] [NEGATIVE] [ZERO]
|
// 3 sections: [POSITIVE/TEXT] [NEGATIVE] [ZERO]
|
||||||
// 4 sections: [POSITIVE] [NEGATIVE] [ZERO] [TEXT]
|
// 4 sections: [POSITIVE] [NEGATIVE] [ZERO] [TEXT]
|
||||||
$cnt = count($sections);
|
$cnt = count($sections);
|
||||||
$color_regex = '/\\[(' . implode('|', Color::NAMED_COLORS) . ')\\]/';
|
$color_regex = '/\\[(' . implode('|', Color::NAMED_COLORS) . ')\\]/mui';
|
||||||
$cond_regex = '/\\[(>|>=|<|<=|=|<>)([+-]?\\d+([.]\\d+)?)\\]/';
|
$cond_regex = '/\\[(>|>=|<|<=|=|<>)([+-]?\\d+([.]\\d+)?)\\]/';
|
||||||
$colors = ['', '', '', '', ''];
|
$colors = ['', '', '', '', ''];
|
||||||
$condops = ['', '', '', '', ''];
|
$condops = ['', '', '', '', ''];
|
||||||
|
|
@ -139,7 +139,7 @@ class Formatter
|
||||||
// datetime format
|
// datetime format
|
||||||
$value = DateFormatter::format($value, $format);
|
$value = DateFormatter::format($value, $format);
|
||||||
} else {
|
} else {
|
||||||
if (substr($format, 0, 1) === '"' && substr($format, -1, 1) === '"') {
|
if (substr($format, 0, 1) === '"' && substr($format, -1, 1) === '"' && substr_count($format, '"') === 2) {
|
||||||
$value = substr($format, 1, -1);
|
$value = substr($format, 1, -1);
|
||||||
} elseif (preg_match('/[0#, ]%/', $format)) {
|
} elseif (preg_match('/[0#, ]%/', $format)) {
|
||||||
// % number format
|
// % number format
|
||||||
|
|
|
||||||
|
|
@ -390,6 +390,11 @@ return [
|
||||||
12345,
|
12345,
|
||||||
'[Green]General',
|
'[Green]General',
|
||||||
],
|
],
|
||||||
|
[
|
||||||
|
'12345',
|
||||||
|
12345,
|
||||||
|
'[GrEeN]General',
|
||||||
|
],
|
||||||
[
|
[
|
||||||
'-70',
|
'-70',
|
||||||
-70,
|
-70,
|
||||||
|
|
@ -404,14 +409,24 @@ return [
|
||||||
[
|
[
|
||||||
'12345',
|
'12345',
|
||||||
12345,
|
12345,
|
||||||
'[Blue]0;[Red]0',
|
'[Blue]0;[Red]0-',
|
||||||
],
|
],
|
||||||
|
[
|
||||||
|
'12345-',
|
||||||
|
-12345,
|
||||||
|
'[BLUE]0;[red]0-',
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'12345-',
|
||||||
|
-12345,
|
||||||
|
'[blue]0;[RED]0-',
|
||||||
|
],
|
||||||
|
// Multiple colors with text substitution
|
||||||
[
|
[
|
||||||
'Positive',
|
'Positive',
|
||||||
12,
|
12,
|
||||||
'[Green]"Positive";[Red]"Negative";[Blue]"Zero"',
|
'[Green]"Positive";[Red]"Negative";[Blue]"Zero"',
|
||||||
],
|
],
|
||||||
// Multiple colors with text substitution
|
|
||||||
[
|
[
|
||||||
'Zero',
|
'Zero',
|
||||||
0,
|
0,
|
||||||
|
|
@ -422,6 +437,7 @@ return [
|
||||||
-2,
|
-2,
|
||||||
'[Green]"Positive";[Red]"Negative";[Blue]"Zero"',
|
'[Green]"Positive";[Red]"Negative";[Blue]"Zero"',
|
||||||
],
|
],
|
||||||
|
// Value break points
|
||||||
[
|
[
|
||||||
'<=3500 red',
|
'<=3500 red',
|
||||||
3500,
|
3500,
|
||||||
|
|
@ -442,6 +458,17 @@ return [
|
||||||
25,
|
25,
|
||||||
'[Green][<>25]"<>25 green";[Red]"else red"',
|
'[Green][<>25]"<>25 green";[Red]"else red"',
|
||||||
],
|
],
|
||||||
|
// Leading/trailing quotes in mask
|
||||||
|
[
|
||||||
|
'$12.34 ',
|
||||||
|
12.34,
|
||||||
|
'$#,##0.00_;[RED]"($"#,##0.00")"',
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'($12.34)',
|
||||||
|
-12.34,
|
||||||
|
'$#,##0.00_;[RED]"($"#,##0.00")"',
|
||||||
|
],
|
||||||
[
|
[
|
||||||
'pfx. 25.00',
|
'pfx. 25.00',
|
||||||
25,
|
25,
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue