Reputation: 827
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
Upvotes: 0
Views: 4777
Reputation: 606
I have solved this by replacing line 1688 in /PHPExcel/Classes/PHPExcel/Reader/Excel2007.php
Main:
$activeTab = intval($xmlWorkbook->bookViews->workbookView["activeTab"]);
Replaced:
$activeTab =isset($xmlWorkbook->bookViews->workbookView["activeTab"])? intval($xmlWorkbook->bookViews->workbookView["activeTab"]):"sheet1";
Upvotes: 0
Reputation: 506
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.
Upvotes: 3
Reputation: 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
Upvotes: 0