Formula Error: Unexpected operator '=' in /vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Cell/Cell.php:563
I always had an issue with saving large amounts of data (e.g. 10K or entries), but they all ended with 504 Gateway Timeout error. I updated the library to the latest and now I'm getting this when I try to save such documents (small ones are saved without any issues):
Next PhpOffice\PhpSpreadsheet\Calculation\Exception: Worksheet!Z3280 -> Formula Error: Unexpected operator '=' in /vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Cell/Cell.php:563
Stack trace:
#0 /vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Writer/Xlsx/Worksheet.php(1564): PhpOffice\PhpSpreadsheet\Cell\Cell->getCalculatedValue()
#1 /vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Writer/Xlsx/Worksheet.php(1729): PhpOffice\PhpSpreadsheet\Writer\Xlsx\Worksheet->writeCellFormula()
#2 /vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Writer/Xlsx/Worksheet.php(1487): PhpOffice\PhpSpreadsheet\Writer\Xlsx\Worksheet->writeCell()
#3 /vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Writer/Xlsx/Worksheet.php(101): PhpOffice\PhpSpreadsheet\Writer\Xlsx\Worksheet->writeSheetData()
#4 /vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Writer/Xlsx.php(398): PhpOffice\PhpSpreadsheet\Writer\Xlsx\Worksheet->writeWorksheet()
#5 PhpOffice\PhpSpreadsheet\Writer\Xlsx->save()
I don't think there's anything I can do without seeing the failing file. Because it needs to be very large, I'm not sure there's anything I can do even if I do see it. Can you upload it?
Problem is that it fails to save the file and only the big one somehow. Smaller files are saved just fine. Is there a temp file?
As a workaround, you should try saving with preCalculateFormulas off. That should allow you to save, and the resulting file should be usable.
I set this before saving the file:
$writer->setPreCalculateFormulas(false);
File was finally saved, however when I tried to open it in Excel it returned "We found a problem with some content in export.xlxs file. Do you want us to try to recover as much as we can?". It eventually opened it and everything seems right at a first glance, but I can't say for sure. My document doesn't have any formulas though, I basically do the export from MySQL database into CSV/Excel files.
As I said, there isn't much I can do without seeing the file. We get a fair number of reports of Excel complaining, and very rarely does it give any useful information about what it's complaining about. Often, as in your case, letting it do what it thinks it needs to yields a completely usable file. Which isn't particularly satisfactory but ...
Your stack trace, and the fact that setting preCalculateFormulas off sort of helps, seems to indicate that you do have a formula somewhere in your spreadsheet.
My script literally just takes the data from MySQL DB table and exports it in CSV/Excel file. Definitely no formulas. Also, it returns the same "Unexpected operator '='" message for both Excel and CSV, which doesn't make sense to me since the latter doesn't have any formulas.