Fix for worksheet lookup for worksheets with spaces in the title
Sheet titles containing " " or "!" will be quoted in formulas. This commit fixes the lookup of sheets with this kind of title by trimming the quotes during the lookup. Without this any defined range referencing a sheet with " " or "!" in the title name will be lost when reading the workbook from file. Fixes #928 Closes 930
This commit is contained in:
parent
f6f1ef2893
commit
98a1f0a8cf
|
@ -21,6 +21,7 @@ and this project adheres to [Semantic Versioning](https://semver.org).
|
|||
- 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)
|
||||
- Fix handling of named ranges referencing sheets with spaces or "!" in their title
|
||||
|
||||
## [1.8.2] - 2019-07-08
|
||||
|
||||
|
|
|
@ -721,7 +721,7 @@ class Spreadsheet
|
|||
{
|
||||
$worksheetCount = count($this->workSheetCollection);
|
||||
for ($i = 0; $i < $worksheetCount; ++$i) {
|
||||
if ($this->workSheetCollection[$i]->getTitle() === $pName) {
|
||||
if ($this->workSheetCollection[$i]->getTitle() === trim($pName, "'")) {
|
||||
return $this->workSheetCollection[$i];
|
||||
}
|
||||
}
|
||||
|
|
|
@ -137,6 +137,7 @@ class WorksheetTest extends TestCase
|
|||
['B2', '', '', 'B2'],
|
||||
['testTitle!B2', 'testTitle', 'B2', 'B2'],
|
||||
['test!Title!B2', 'test!Title', 'B2', 'B2'],
|
||||
['test Title!B2', 'test Title', 'B2', 'B2'],
|
||||
];
|
||||
}
|
||||
|
||||
|
|
|
@ -81,4 +81,14 @@ return [
|
|||
'\'Worksheet1\'!A16',
|
||||
'123',
|
||||
],
|
||||
[
|
||||
true,
|
||||
'A17',
|
||||
'=\'Work sheet1\'!A1',
|
||||
],
|
||||
[
|
||||
true,
|
||||
'A18',
|
||||
'=\'Work!sheet1\'!A1',
|
||||
],
|
||||
];
|
||||
|
|
|
@ -21,11 +21,26 @@ return [
|
|||
'A4',
|
||||
'=\'Worksheet1\'!A1',
|
||||
],
|
||||
[
|
||||
'=\'Works heet1\'!A1',
|
||||
'A4',
|
||||
'=\'Works heet1\'!A1',
|
||||
],
|
||||
[
|
||||
'="HELLO WORLD"',
|
||||
'\'Worksheet1\'!A5',
|
||||
'="HELLO WORLD"',
|
||||
],
|
||||
[
|
||||
'="HELLO WORLD"',
|
||||
'\'Work sheet1\'!A5',
|
||||
'="HELLO WORLD"',
|
||||
],
|
||||
[
|
||||
'="HELLO WORLD"',
|
||||
'\'Work!sheet1\'!A5',
|
||||
'="HELLO WORLD"',
|
||||
],
|
||||
[
|
||||
'#N/A',
|
||||
'\'Worksheet1\'!A6',
|
||||
|
|
Loading…
Reference in New Issue