I know there are many posts with this same error but none of them seem to address this particular issue.
I am upgrading an app using PHPSpreadsheet from PHP 7.3.22 to 7.4.6. PHP 7.4.6 is throwing a null exception error when setting a formula in a cell. The following snippet illustrates the problem:
$file_name = './uploads/helloworld.xlsx';
$spreadsheet = new \PhpOffice\PhpSpreadsheet\Spreadsheet();
// these lines work with PHP Versions 7.3.22 and 7.4.6
$spreadsheet->getActiveSheet()->setCellValue('A1', '1');
$spreadsheet->getActiveSheet()->setCellValue('A2', '2');
// this line causes the exception only with PHP Version 7.4.6
$spreadsheet->getActiveSheet()->setCellValue('A3', "=A1+A2");
$writer = new \PhpOffice\PhpSpreadsheet\Writer\Xlsx($spreadsheet);
// the exception gets thrown here
$writer->save($file_name);
$spreadsheet->disconnectWorksheets();
unset($spreadsheet);
Any advice appreciated - thanks - Jon