skip to Main Content

Version:

composer.json :

    "require": {
        "php": "^8.0.1",
        "ext-zip": "*",
        "laravel/framework": "^8.25",
        "laravel/tinker": "^2.6",
        "laravel/ui": "^3.2",
        "phpoffice/phpspreadsheet": "^1.16"


Problem:

ErrorException
Trying to access array offset on value of type null


After upgrading to Laravel 8 and PHP 8. I’m getting above error.

<?php

use PHPExcel_Reader_Excel2007;


$objReader = new PHPExcel_Reader_Excel2007();
$objReader->setReadDataOnly(true);
$objPHPExcel = $objReader->load('/path/to/filename.xlsx'); // This line

2

Answers


  1. it seems that the file is missing some property, what i did and that worked is i have the file with libreOffliceCal and i did a ctrl + s to save and when i tried again i no longer had this mistake

    Login or Signup to reply.
  2. Find the line of the error at the library file, in my case was some array that should not be null $attributes[$t] I’ve change it.

    if ($attributes['t'] == 'array') { //from this
    if (isset($attributes['t']) && $attributes['t'] == 'array') { //to this
    

    the error dissapeared.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search