PHPOffice / PhpSpreadsheet

A pure PHP library for reading and writing spreadsheet files
https://phpspreadsheet.readthedocs.io
MIT License
13.39k stars 3.48k forks source link

Reading a sheet protected Excel file (saved in Mac OS) is not working #3423

Open chiborg opened 1 year ago

chiborg commented 1 year ago

This is:

- [x] 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 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

MarkBaker commented 1 year ago

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

chiborg commented 1 year ago

Protected, not encrypted. The problem is only with Excel for Mac. When I load a file, what save on Windows or Linux Libreoffice, every codes are working.

MarkBaker commented 1 year ago

So another odd difference between Windows Excel and Mac Excel.

Is it possible to attach example files?

vladojovanovski commented 1 year ago

EDAS-ART IMAGINATION-2023-200.xlsx example attached

oleibman commented 1 year ago

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.