Phpspreadsheet: Trying to access array offset on value of type int in /vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Cell/DefaultValueBinder.php on line 59

Created on 29 Dec 2019  路  2Comments  路  Source: PHPOffice/PhpSpreadsheet

This is:

- [ ] a bug report
- [ ] a feature request
- [ ] **not** a usage question (ask them on https://stackoverflow.com/questions/tagged/phpspreadsheet or https://gitter.im/PHPOffice/PhpSpreadsheet)

What is the expected behavior?

when I bind an int type value, I just want to see no warnings.

What is the current behavior?

PHP Notice: Trying to access array offset on value of type int in /vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Cell/DefaultValueBinder.php on line 59

the code on line 59 list below:

 } elseif ($pValue[0] === '=' && strlen($pValue) > 1) {
            return DataType::TYPE_FORMULA;
        }

the type of $pValue is int.

What are the steps to reproduce?

Please provide a Minimal, Complete, and Verifiable example of code that exhibits the issue without relying on an external Excel file or a web server:

<?php

require __DIR__ . '/vendor/autoload.php';

// Create new Spreadsheet object
$spreadsheet = new \PhpOffice\PhpSpreadsheet\Spreadsheet();

$pValue  = (int) 100;
$pCoordination = 'A1';
$spreadsheet->getActiveSheet()->setCellValue($pCoordination, $pValue);

Which versions of PhpSpreadsheet and PHP are affected?

PhpSpreadsheet: 1.8.2
PHP version: 7.4

Most helpful comment

This issue was fixed in release 1.10.0 of PHPSpreadsheet

All 2 comments

PHP version is important here, I encountered this when I upgraded from 7.1 to 7.4, downgraded to 7.3 and it doesn't throw the error.

This issue was fixed in release 1.10.0 of PHPSpreadsheet

Was this page helpful?
0 / 5 - 0 ratings