-
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
Reading a sheet protected Excel file (saved in Mac OS) is not working #3423
Comments
Are these protected spreadsheet files? Or are they encrypted? PhpSpreadsheet can't read encrypted files. Otherwise I'd need to look at the actual files themselves to see exactly what the problem was |
Protected, not encrypted. |
So another odd difference between Windows Excel and Mac Excel. Is it possible to attach example files? |
|
Thank you for uploading the file. PhpSpreadsheet does have a problem with it, but I think it is unrelated to this issue. I will open a new one for it. |
Fix PHPOffice#3720. Third-party product created a spreadsheet which PhpSpreadsheet could not read because of unexpected namespacing in workbook.xml.rels. The file which demonstrated the problem was attached to PHPOffice#3423, however I do not believe it was related to the original problem. Nevertheless, the original issue specifically called out Protection, so I put some Protection tests in the validation test for the fix. In doing so, I found that Style/Protection is particularly confusing. Its properties will often have the value `inherit`, which isn't all that helpful; and, even when the `locked` value is `protected`, the cell won't actually be locked unless the sheet is protected as well. The `hidden` property is even more obscure - it applies only to formulas, and refers to hiding the property on the formula bar, not in the cell. I have added methods `isLocked` and `isHiddenOnFormulaBar` to `Cell`. I corrected the docs to explain this. And, as long as I was looking at the docs, I corrected some examples to use `getHighestDataRow/Column` rather than `getHighestRow/Column`, a frequent problem for users (e.g. PHPOffice#3721). As a side note, the change to Cell.php is my first use of the nullsafe operator. This is one of many new options available now that we require Php8.0+.
* Unexpected Namespacing in rels File Fix #3720. Third-party product created a spreadsheet which PhpSpreadsheet could not read because of unexpected namespacing in workbook.xml.rels. The file which demonstrated the problem was attached to #3423, however I do not believe it was related to the original problem. Nevertheless, the original issue specifically called out Protection, so I put some Protection tests in the validation test for the fix. In doing so, I found that Style/Protection is particularly confusing. Its properties will often have the value `inherit`, which isn't all that helpful; and, even when the `locked` value is `protected`, the cell won't actually be locked unless the sheet is protected as well. The `hidden` property is even more obscure - it applies only to formulas, and refers to hiding the property on the formula bar, not in the cell. I have added methods `isLocked` and `isHiddenOnFormulaBar` to `Cell`. I corrected the docs to explain this. And, as long as I was looking at the docs, I corrected some examples to use `getHighestDataRow/Column` rather than `getHighestRow/Column`, a frequent problem for users (e.g. #3721). As a side note, the change to Cell.php is my first use of the nullsafe operator. This is one of many new options available now that we require Php8.0+. * Minor Simplifications * Scrutinizer It's being silly again. In many tests, we test a variable for non-null, then use that variable later and Scrutinizer knows it's not null. Not here. Oh well. * Add Methods Test if protected without allocating cell if it doesn't exist.
This is:
What is the current behavior?
This code is not working when opens an XLS type file:
$objPHPExcel = IOFactory::load($file->getRealPath());
The error message is:
Unexpected file pass record length
This code is not working when opens an XLSX type file:
$string = $objPHPExcel->getActiveSheet()->getCell('A1')->getValue()
The error message is:
Your requested sheet index: -1 is out of bounds. The actual number of sheets is 0.
What are the steps to reproduce?
The files was created by Excel for Mac.
There only one sheet, what have write protected cells with password.
Does an issue affect all spreadsheet file formats? If not, which formats are affected?
XLS
XLSX
Which versions of PhpSpreadsheet and PHP are affected?
PhpSpreadsheet version: 1.28.0
php version: 8.1.3
The text was updated successfully, but these errors were encountered: