-
Notifications
You must be signed in to change notification settings - Fork 3.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
After patching PHPSpreadsheet 4.0.0 with PR #4360, in a sheet with a title containing an apostrophe, applying a style format to a named cell crashes the application. #4362
Comments
The code sample you show above has the following statement: $style = $sheet->getStyle($cellName); However, I see nothing in the code which initializes $cellName. Please supply new code with this problem corrected. |
Thank you for your reply! My mistake. I have now updated the code sample in the original post. |
I don't think this combination will work: $cellName = 'CELLNAME';
$style = $sheet->getStyle($cellName); Might you have meant the following? $style = $sheet->getStyle($namedRange->getRange()); That also has problems, with or without an apostrophe, and I am researching that. There also appear to be several other areas of code which might have similar problems. I am researching those as well. It might take a couple of days. |
Well, these calls
have worked for us so far. The call in Worksheet/Worksheet.php at line 1404 It may be a series of fortunate unintended consequences of the series of calls in |
Live and learn - no need for you to change your code. I thought my testing indicated that it didn't work, but I was up late so probably wasn't paying enough attention. |
Fix PHPOffice#4362. A similar problem to 4360, Style not handling sheet name with embedded apostrophe properly. And, with two examples in hand, I was able to determine a pattern to find and fix other possible exposures.
Please try 4360 again. |
Hi! I've tested the new patches in PR #4360 and I can confirm applying a style to the named cells in a sheet containing an apostrophe in its title works! I believe this issue can now be closed. |
This is:
What is the expected behavior?
Follow-up issue to issue #4356, PR #4360 is applied.
The application of a number format to a cell in a sheet containing an apostrophe should apply the format properly.
What is the current behavior?
The application crashes with exception 'Invalid Worksheet for specified Range' (Style/Style.php line 194).
What are the steps to reproduce?
Observe the crash.
Here is an Excel file to reproduce this behavior with: Problematic sheet name.xlsx
What features do you think are causing the issue
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: 4.0.0
PHP: 8.1
The text was updated successfully, but these errors were encountered: