You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I've confirmed that most of the program works just fine, but when it reaches "$writer->save($fileName)" it throws this error:
PHP Warning: Undefined array key "" in C:\inetpub\wwwroot\vendor\phpoffice\phpspreadsheet\src\PhpSpreadsheet\Calculation\Calculation.php on line 4367 PHP Fatal error: Uncaught TypeError: array_keys(): Argument #1 ($array) must be of type array, null given in C:\inetpub\wwwroot\vendor\phpoffice\phpspreadsheet\src\PhpSpreadsheet\Calculation\Calculation.php:4367 Stack trace: #0 C:\inetpub\wwwroot\vendor\phpoffice\phpspreadsheet\src\PhpSpreadsheet\Calculation\Calculation.php(4367): array_keys(NULL) #1 C:\inetpub\wwwroot\vendor\phpoffice\phpspreadsheet\src\PhpSpreadsheet\Calculation\Calculation.php(4487): PhpOffice\PhpSpreadsheet\Calculation\Calculation::dataTestReference(Array) #2 C:\inetpub\wwwroot\vendor\phpoffice\phpspreadsheet\src\PhpSpreadsheet\Calculation\Calculation.php(3539): PhpOffice\PhpSpreadsheet\Calculation\Calculation->processTokenStack(Array, 'B2', Object(PhpOffice\PhpSpreadsheet\Cell\Cell)) #3 C:\inetpub\wwwroot\vendor\phpoffice\phpspreadsheet\src\PhpSpreadsheet\Calculation\Calculation.php(3332): PhpOffice\PhpSpreadsheet\Calculation\Calculation->_calculateFormulaValue('IFERROR(IF(INDI...', 'B2', Object(PhpOffice\PhpSpreadsheet\Cell\Cell)) #4 C:\inetpub\wwwroot\vendor\phpoffice\phpspreadsheet\src\PhpSpreadsheet\Cell\Cell.php(259): PhpOffice\PhpSpreadsheet\Calculation\Calculation->calculateCellValue(Object(PhpOffice\PhpSpreadsheet\Cell\Cell), true) #5 C:\inetpub\wwwroot\vendor\phpoffice\phpspreadsheet\src\PhpSpreadsheet\Writer\Xlsx\Worksheet.php(1229): PhpOffice\PhpSpreadsheet\Cell\Cell->getCalculatedValue() #6 C:\inetpub\wwwroot\vendor\phpoffice\phpspreadsheet\src\PhpSpreadsheet\Writer\Xlsx\Worksheet.php(1300): PhpOffice\PhpSpreadsheet\Writer\Xlsx\Worksheet->writeCellFormula(Object(PhpOffice\PhpSpreadsheet\Shared\XMLWriter), '=IFERROR(IF(IND...', Object(PhpOffice\PhpSpreadsheet\Cell\Cell)) #7 C:\inetpub\wwwroot\vendor\phpoffice\phpspreadsheet\src\PhpSpreadsheet\Writer\Xlsx\Worksheet.php(1156): PhpOffice\PhpSpreadsheet\Writer\Xlsx\Worksheet->writeCell(Object(PhpOffice\PhpSpreadsheet\Shared\XMLWriter), Object(PhpOffice\PhpSpreadsheet\Worksheet\Worksheet), 'B2', Array) #8 C:\inetpub\wwwroot\vendor\phpoffice\phpspreadsheet\src\PhpSpreadsheet\Writer\Xlsx\Worksheet.php(70): PhpOffice\PhpSpreadsheet\Writer\Xlsx\Worksheet->writeSheetData(Object(PhpOffice\PhpSpreadsheet\Shared\XMLWriter), Object(PhpOffice\PhpSpreadsheet\Worksheet\Worksheet), Array) #9 C:\inetpub\wwwroot\vendor\phpoffice\phpspreadsheet\src\PhpSpreadsheet\Writer\Xlsx.php(377): PhpOffice\PhpSpreadsheet\Writer\Xlsx\Worksheet->writeWorksheet(Object(PhpOffice\PhpSpreadsheet\Worksheet\Worksheet), Array, false) #10 C:\inetpub\wwwroot\App\Services\export-excel-cg.php(57): PhpOffice\PhpSpreadsheet\Writer\Xlsx->save('../../Public/Fi...') #11 {main} thrown in C:\inetpub\wwwroot\vendor\phpoffice\phpspreadsheet\src\PhpSpreadsheet\Calculation\Calculation.php on line 4367
I've tried running this program with a blank excel document and I didn't get any errors when I did. I don't think there's anything in the excel file I'm testing with that should trip it up, but I'm not totally sure based on the documentation. Has anyone else run into this?
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
I have a simple program that opens a spreadsheet, adds a test phrase to cell A6, and writes the result to a new file:
`use PhpOffice\PhpSpreadsheet\Reader\Xlsx as Reader;
use PhpOffice\PhpSpreadsheet\Spreadsheet;
use PhpOffice\PhpSpreadsheet\Writer\Xlsx as Writer;
$docLocation = "[file location]";
$reader = new Reader();
$spreadsheet = $reader->load($docLocation);
// $sheet = $spreadsheet->getSheet(0);
// $sheet->setCellValue('A6', 'Test');
$writer = new Writer($spreadsheet);
$fileName = "[new file location]";
$writer->save($fileName);
var_dump($fileName);`
I've confirmed that most of the program works just fine, but when it reaches "$writer->save($fileName)" it throws this error:
PHP Warning: Undefined array key "" in C:\inetpub\wwwroot\vendor\phpoffice\phpspreadsheet\src\PhpSpreadsheet\Calculation\Calculation.php on line 4367 PHP Fatal error: Uncaught TypeError: array_keys(): Argument #1 ($array) must be of type array, null given in C:\inetpub\wwwroot\vendor\phpoffice\phpspreadsheet\src\PhpSpreadsheet\Calculation\Calculation.php:4367 Stack trace: #0 C:\inetpub\wwwroot\vendor\phpoffice\phpspreadsheet\src\PhpSpreadsheet\Calculation\Calculation.php(4367): array_keys(NULL) #1 C:\inetpub\wwwroot\vendor\phpoffice\phpspreadsheet\src\PhpSpreadsheet\Calculation\Calculation.php(4487): PhpOffice\PhpSpreadsheet\Calculation\Calculation::dataTestReference(Array) #2 C:\inetpub\wwwroot\vendor\phpoffice\phpspreadsheet\src\PhpSpreadsheet\Calculation\Calculation.php(3539): PhpOffice\PhpSpreadsheet\Calculation\Calculation->processTokenStack(Array, 'B2', Object(PhpOffice\PhpSpreadsheet\Cell\Cell)) #3 C:\inetpub\wwwroot\vendor\phpoffice\phpspreadsheet\src\PhpSpreadsheet\Calculation\Calculation.php(3332): PhpOffice\PhpSpreadsheet\Calculation\Calculation->_calculateFormulaValue('IFERROR(IF(INDI...', 'B2', Object(PhpOffice\PhpSpreadsheet\Cell\Cell)) #4 C:\inetpub\wwwroot\vendor\phpoffice\phpspreadsheet\src\PhpSpreadsheet\Cell\Cell.php(259): PhpOffice\PhpSpreadsheet\Calculation\Calculation->calculateCellValue(Object(PhpOffice\PhpSpreadsheet\Cell\Cell), true) #5 C:\inetpub\wwwroot\vendor\phpoffice\phpspreadsheet\src\PhpSpreadsheet\Writer\Xlsx\Worksheet.php(1229): PhpOffice\PhpSpreadsheet\Cell\Cell->getCalculatedValue() #6 C:\inetpub\wwwroot\vendor\phpoffice\phpspreadsheet\src\PhpSpreadsheet\Writer\Xlsx\Worksheet.php(1300): PhpOffice\PhpSpreadsheet\Writer\Xlsx\Worksheet->writeCellFormula(Object(PhpOffice\PhpSpreadsheet\Shared\XMLWriter), '=IFERROR(IF(IND...', Object(PhpOffice\PhpSpreadsheet\Cell\Cell)) #7 C:\inetpub\wwwroot\vendor\phpoffice\phpspreadsheet\src\PhpSpreadsheet\Writer\Xlsx\Worksheet.php(1156): PhpOffice\PhpSpreadsheet\Writer\Xlsx\Worksheet->writeCell(Object(PhpOffice\PhpSpreadsheet\Shared\XMLWriter), Object(PhpOffice\PhpSpreadsheet\Worksheet\Worksheet), 'B2', Array) #8 C:\inetpub\wwwroot\vendor\phpoffice\phpspreadsheet\src\PhpSpreadsheet\Writer\Xlsx\Worksheet.php(70): PhpOffice\PhpSpreadsheet\Writer\Xlsx\Worksheet->writeSheetData(Object(PhpOffice\PhpSpreadsheet\Shared\XMLWriter), Object(PhpOffice\PhpSpreadsheet\Worksheet\Worksheet), Array) #9 C:\inetpub\wwwroot\vendor\phpoffice\phpspreadsheet\src\PhpSpreadsheet\Writer\Xlsx.php(377): PhpOffice\PhpSpreadsheet\Writer\Xlsx\Worksheet->writeWorksheet(Object(PhpOffice\PhpSpreadsheet\Worksheet\Worksheet), Array, false) #10 C:\inetpub\wwwroot\App\Services\export-excel-cg.php(57): PhpOffice\PhpSpreadsheet\Writer\Xlsx->save('../../Public/Fi...') #11 {main} thrown in C:\inetpub\wwwroot\vendor\phpoffice\phpspreadsheet\src\PhpSpreadsheet\Calculation\Calculation.php on line 4367
I've tried running this program with a blank excel document and I didn't get any errors when I did. I don't think there's anything in the excel file I'm testing with that should trip it up, but I'm not totally sure based on the documentation. Has anyone else run into this?
Beta Was this translation helpful? Give feedback.
All reactions