php - PhpSpreadsheet: "Undefined offset" and "trim() expects parameter 1 to be string"


I get the following error and I'm trying to figure out if it's something in my code or if my template is causing the error. I can upload the template if needed, but thought I'd check if I've missed something obvious or if this is a known problem first.

Notice: Undefined offset: 2 in /vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/Calculation.php on line 3472

Warning: trim() expects parameter 1 to be string, array given in /vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/Calculation.php on line 3680

require 'vendor/autoload.php';

use PhpOffice\PhpSpreadsheet\Spreadsheet;
use PhpOffice\PhpSpreadsheet\Writer\Xlsx;

$reader = \PhpOffice\PhpSpreadsheet\IOFactory::createReader('Xlsx');
$spreadsheet = $reader->load("template.xlsx");

$writer = \PhpOffice\PhpSpreadsheet\IOFactory::createWriter($spreadsheet, 'Xlsx');

Edit// I tried a different template and I don't get the error, so template can be found here...

People are also looking for solutions to the problem: javascript - How to change text colour based on conditions?


Didn't find the answer?

Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.

Ask a Question

Write quick answer

Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.

Similar questions

Find the answer in similar questions on our website.