Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

XLS 2003 VSLOOKUP parsing error #4331

Closed
bbinotto-redline opened this issue Jan 28, 2025 · 1 comment · Fixed by #4333
Closed

XLS 2003 VSLOOKUP parsing error #4331

bbinotto-redline opened this issue Jan 28, 2025 · 1 comment · Fixed by #4333

Comments

@bbinotto-redline
Copy link

bbinotto-redline commented Jan 28, 2025

Tested with Version 3.9.0

The Following Code produces the error:
"PhpOffice\PhpSpreadsheet\Writer\Xls\Parser::convertFunction(): Argument #2 ($num_args) must be of type int, string given"

Code:

        $reader = IOFactory::createReader(IOFactory::READER_XLS);
        $reader->setReadDataOnly(true);
        $excel = $reader->load(dirname(__FILE__).'/VSLOOKUP_example_2003.xls');
        $writer = IOFactory::createWriter($excel, IOFactory::WRITER_XLS);
        $writer->save(dirname(__FILE__).'/VSLOOKUP_output_2003.xls');

File (German XLS File with German Function Name 'SVERWEIS' for 'VSLOOKUP':
VSLOOKUP_example_2003.xls

@oleibman
Copy link
Collaborator

Thank you for the sample file. There have been recent changes to Writer/Xls/Parser, but I have confirmed that this problem existed before those changes. What appears to be happening is that Parser is treating FALSE (or TRUE) as a function rather than a constant, which is nominally a harmless difference. However, since it wasn't a function, when it tries to parse the arguments, the field in which it expects the argument count is null-string rather than 0. Expect a fix within a day or two.

oleibman added a commit to oleibman/PhpSpreadsheet that referenced this issue Jan 29, 2025
Fix PHPOffice#4331. Parser treats TRUE/FALSE as functions rather than constants, which is nominally harmless, but it then expects an argument count of 0 and instead sees null-string. Changed to recognize this situation and leave TRUE/FALSE/TRUE()/FALSE() unchanged.
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Development

Successfully merging a pull request may close this issue.

2 participants