Skip to content
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

Inconsistent handling of empty parameters in formulas between PhpSpreadsheet and Excel #3866

Closed
1 task done
jonas-grobe opened this issue Jan 13, 2024 · 0 comments · Fixed by #3868
Closed
1 task done

Comments

@jonas-grobe
Copy link

This is a bug report.

What is the expected behavior?

Excel seems to treat empty parameters as 0, =MIN(3,2,) evaluates to 0.

What is the current behavior?

=MIN(3,2,) evaluates to 2 in PHPSpreadsheet.

What are the steps to reproduce?

<?php

require __DIR__ . '/vendor/autoload.php';

$spreadsheet = new \PhpOffice\PhpSpreadsheet\Spreadsheet();
$sheet = $spreadsheet->getActiveSheet();
$formula = '=MIN(3,2,)';
$sheet->setCellValue('A1', $formula);
$cellValue = $sheet->getCell('A1')->getCalculatedValue();
echo "Result of MIN(3,2,): $cellValue"; // PHPSpreadsheet: 2, Excel: 0

What features do you think are causing the issue

  • Formula Calculations

Which versions of PhpSpreadsheet and PHP are affected?

Tested on PHPSpreadsheet 1.29.0 with PHP 8.0.12

oleibman added a commit to oleibman/PhpSpreadsheet that referenced this issue Jan 15, 2024
Fix PHPOffice#3866. Excel normally treats a missing argument (e.g. `PRODUCT(2,3,)`) as null and ignores it. Not so for MIN/MAX/MINA/MAXA; for those, an empty argument is treated as zero. PhpSpreadsheet is changed to do the same.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging a pull request may close this issue.

1 participant