KoolReport's Forum

Official Support Area, Q&As, Discussions, Suggestions and Bug reports.
Forum's Guidelines

Outdated phpoffice? PHP 7.4 returns "Trying to access array offset on value of type int" #1427

Closed Locness Tecnologia e Inovação opened this topic on on May 6, 2020 - 1 comments

Locness Tecnologia e Inovação commented on May 6, 2020

We have downloaded and installed KR Pro via zip file.

We're trying to generate multiple reports from the same array. Example:

[
    ["ID"],
    [1]
]

Our report exports successfully to CSV, PNG and PDF.

However, when trying to export to XLSX, we get the error:

"message": "Trying to access array offset on value of type int",
    "exception": "ErrorException",
    "file": "(...)/koolreport/excel/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Cell/DefaultValueBinder.php",
    "line": 58,

It happens when PhpOffice\PhpSpreadsheet\Cell\DefaultValueBinder::dataTypeForValue takes $value = (int) 1 as an input

This is the line that throws the error. It comes before making sure $pValue is not an integer:

        } elseif ($pValue[0] === '=' && strlen($pValue) > 1) {

The thing is, this has been corrected in PhpOffice in july 2019:

https://github.com/PHPOffice/PhpSpreadsheet/commit/a691516664f48790bec8e4f2005e37cc0215cd82

Is it expected that PHPoffice will be updated in the KRPro zip pack anytime to avoid this error?

David Winterburn commented on May 7, 2020

Hi,

You are correct. We will update phpoffice/phpspreadsheet's version requirement in the next release of KoolReport. Meanwhile you could solve this by either:

1 . Change Excel's composer.json require to:

        ...
        "phpoffice/phpspreadsheet": "^1.10"

and run command: "composer update" in Excel's folder.

2 . Download phpoffice/phpspreadsheet with version >= 1.10 and extract it to Excel/vendor folder.

Let us know if you have any problem with this. Thanks!

Build Your Excellent Data Report

Let KoolReport help you to make great reports. It's free & open-source released under MIT license.

Download KoolReport View demo
solved

Excel