Closed
Description
This is:
- 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?
The global named cells reference the cells in the sheet containing a quote in its title when opened.
What is the current behavior?
The names of the named cells do not reference the cells they were referencing.
What are the steps to reproduce?
Open an Xlsx file containing a named cell in a sheet with a title containing an apostrophe, and call Spreadsheet::getNamedRange("CELLNAME");
$reader = IOFactory::createReader('Xlsx');
$spreadsheet = $reader->load($filePath);
$cellrange = $spreadsheet->getNamedRange("CELLNAME");
var_dump($cellrange);
Observe the empty result.
Here is an Excel file to reproduce this behavior with: Problematic sheet name.xlsx
What features do you think are causing the issue
- Reader
- Writer
- Styles
- Data Validations
- Formula Calculations
- Charts
- AutoFilter
- Form Elements
The problematic behavior is located in the method Xlsx::loadSpreadsheetFromFile in the file Reader/Xlsx.php. Adding the following code at line 1825 crudely fixes the problem:
$extractedSheetName = str_replace("''", "'", $extractedSheetName);
Does an issue affect all spreadsheet file formats? If not, which formats are affected?
Not to my knowledge. The affected file format is Xlsx.
Which versions of PhpSpreadsheet and PHP are affected?
PhpSpreadsheet: 3.9.1
PHP: 8.1
Metadata
Metadata
Assignees
Labels
No labels