-
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
listWorksheetInfo() not working without load() for Xls reader with BIFF7 file #3671
Comments
Confirmed; I can duplicate this problem with samples/templates/30templatebiff5.xls. |
oleibman
added a commit
to oleibman/PhpSpreadsheet
that referenced
this issue
Aug 10, 2023
Fix PHPOffice#3671. Xls reader was not processing Code Page as part of functions ListWorksheetInfo/Names, which was causing them to fail for for BIFF5 (and BIFF7); this was not a problem for BIFF8. There were no unit tests for these functions for either BIFF5 or BIFF8. There are now.
11 tasks
oleibman
added a commit
that referenced
this issue
Aug 17, 2023
* Read Code Page for Xls ListWorksheetInfo/Names for BIFF5 Fix #3671. Xls reader was not processing Code Page as part of functions ListWorksheetInfo/Names, which was causing them to fail for for BIFF5 (and BIFF7); this was not a problem for BIFF8. There were no unit tests for these functions for either BIFF5 or BIFF8. There are now. * Add getVersion and getCodePage Methods These came about because test file for non-standard codepage was supposed to be BIFF5, but turned out to be BIFF8 using UTF-16 with some string data otherwise encoded. Add a BIFF5 equivalent (some hex editing was required), and the means to distinguish one from the other. * Found MACCENTRALEUROPE Text in BIFF8 It was used for 'Last Modified By' property, even though bulk of spreadsheet uses UTF-16LE. Add a test.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This is:
What is the expected behavior?
When using Reader\Xls->listWorksheetInfo($path), the reader should initialize itself enough to succeed this feature.
What is the current behavior?
With a BIFF7 file, when using Reader\Xls->listWorksheetInfo($path), codepage is not initialized to its default value, so StringHelper::convertEncoding crash because 3rd argument is null.
What are the steps to reproduce?
I don't know how you would reproduce that without external file but I'll detail what I know about the files.
I noticed that the bug wasn't occuring if I reopen the .xls file and save it with LibreOffice (I don't have excel at reach).
So let's call File A the original one, and File B the A one but opened and saved with LibreOffice.
What I noticed is that
$this->codepage
is only initialized in the loadSpreadsheetFromFile method.But this method needs the BaseReader::load method to be called.
This should not be the case like with any other format.
By calling the
load
method beforelistWorksheetInfo
, it fixes the issue and I then could see the differences between file A and file B.File A was BIFF7 and File B was BIFF8 (which does not need the codepage attribute).
Therefore, File A code page is "MAC" and File B code page is "UTF-16LE".
I don't know how to generate a file A alike, but it probably have been generated from excel on Mac.
Instead of calling the whole
load
method, my current workaround is just setting the codepage value, but of course we should not have to do that.What features do you think are causing the issue
Does an issue affect all spreadsheet file formats? If not, which formats are affected?
Xls BIFF7 (at least), I don't know if other format could be impacted
Which versions of PhpSpreadsheet and PHP are affected?
1.25.2 and 1.29.0
The text was updated successfully, but these errors were encountered: