PhpSpreadsheet: Uncaught PhpOffice\PhpSpreadsheet\Calculation\Exception: Riepilogo!B2 -> Riepilogo!B4 -> Formula Error: An unexpected error occured
This is:
- a bug report
- a feature request
- not a usage question (ask them on https://stackoverflow.com/questions/tagged/phpspreadsheet or https://gitter.im/PHPOffice/PhpSpreadsheet)
What is the expected behavior?
I load an xlsx template I put some test data in cells Write the new file
What is the current behavior?
When reading, get: Uncaught PhpOffice\PhpSpreadsheet\Calculation\Exception: Riepilogo!B2 -> Riepilogo!B4 -> Formula Error: An unexpected error occured
What are the steps to reproduce?
Please provide a Minimal, Complete, and Verifiable example of code that exhibits the issue without relying on an external Excel file or a web server:
To reproduce this bug, first you need to solve the ISSUE #181 as I suggested.
The excel formula is: =SE(SOMMA(B4:B80)=‘Liste presenze’!K8;" “;“ERRORE”) in english =IF(SUM(B4:B80)=‘Liste presenze’!K8;” ";“ERRORE”) To test you need an external excel file, that i attach
<?php
use PhpOffice\PhpSpreadsheet\Spreadsheet;
use PhpOffice\PhpSpreadsheet\Writer\Xlsx;
//Load the file template
$spreadsheet = \PhpOffice\PhpSpreadsheet\IOFactory::load('tabellaperassociazioni.xlsx');
$worksheet = $spreadsheet->getActiveSheet();
//insert test data in some cells
$worksheet->getCell('C3')->setValue('API GENOVA');
$worksheet->getCell('C5')->setValue('22/06/2017');
$worksheet->getCell('A11')->setValue('Messina');
$worksheet->getCell('B12')->setValue('Dario');
$worksheet->getCell('C11')->setValue('Italiano');
$worksheet->getCell('H11')->setValue('ARENZANO');
$writer = \PhpOffice\PhpSpreadsheet\IOFactory::createWriter($spreadsheet, 'Xls');
//write the file
$writer->save('comunicazione.xls');
Which versions of PhpSpreadsheet and PHP are affected?
PhpSpreadsheet = develop PHP 7.0 tabellaperassociazioni.xlsx
About this issue
- Original URL
- State: closed
- Created 7 years ago
- Reactions: 2
- Comments: 23 (4 by maintainers)
same issue here, when we are refering to another sheet in a formula =COUNTIF(Data!K:K;“>=30”), we get the issue reported 😕
Column and Row Ranges have never been supported in formulae by the PHPSpreadsheet Calculation Engine; I’m currently working on them in the new replacement engine, but this is a complete and total rewrite, and takes time
The error seems to be when saving the file, the PHPSpreadsheet tries to read the formulae. I saw that on PHPExcel, lots of people had this problem but were able to solve it calling the method
$objWriter->setPreCalculateFormulas(false);Is there anything like this for PhpSpreadsheet? Couldn’t find in the docs.
the line below gives an error =vlookup(A1,Sheet1!A:B,2,false)
and this one is working =vlookup(A1,Sheet1!A1:B99999,2,false)
so refering to columns on another sheet is not working for me… (both creating from scratch and creating new)
Hi there, I think i have the same issue. when i use a formula with a reference to another sheet, it fails.
after i change the formula to a reference on the same sheet, it will pass… I think you are using different sheets also?
Most of the examples here are using column or row ranges, which are not cleanly supported by PHPSpreadsheet’s calculation engine; references to other sheets in formulae should work, unsupported column or row ranges do not, whether in the same sheet or another sheet
Yes, in the template there are 2 sheets.
I solved, deleting the second sheet 😃 and copying and pasting the first sheet, the one dinamically generated 😃
I know, it’s not a solution, but it works 😃