setCellValueByColumnAndRow is deprecated since 1.23.0 Use the setCellValue() instead

Created on 8 May 2023, about 1 year ago
Updated 3 March 2024, 4 months ago

Problem/Motivation

\PhpOffice\PhpSpreadsheet\Worksheet\Worksheet::setCellValueByColumnAndRow() is deprecated since 1.23.0 Use the setCellValue() instead.

See the change log.

📌 Task
Status

Fixed

Version

1.0

Component

Code

Created by

🇳🇿New Zealand RoSk0 Wellington

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

  • Issue created by @RoSk0
  • First commit to issue fork.
  • Open in Jenkins → Open on Drupal.org →
    Core: 10.1.x + Environment: PHP 8.1 & MySQL 5.7
    last update about 1 year ago
    Composer require failure
  • @ranjit1032002 opened merge request.
  • Open in Jenkins → Open on Drupal.org →
    Core: 10.1.x + Environment: PHP 8.1 & MySQL 5.7
    last update about 1 year ago
    Composer require failure
  • Status changed to Needs review about 1 year ago
  • 🇮🇳India Ranjit1032002

    Created MR!9 for the issue mentioned, please review.
    Thank you.

  • Status changed to Fixed about 1 year ago
  • 🇳🇱Netherlands theemstra

    Tested and reviewed. Thanks for the MR

  • Automatically closed - issue fixed for 2 weeks with no activity.

  • Status changed to Fixed 4 months ago
  • 🇩🇪Germany gngn

    The commited patch did not work for me.
    I got the error:

    Uncaught PHP Exception TypeError: "PhpOffice\\PhpSpreadsheet\\Worksheet\\Worksheet::setCellValue():
      Argument #3 ($binder) must be of type ?PhpOffice\\PhpSpreadsheet\\Cell\\IValueBinder, string given,
      called in modules/contrib/xls_serialization/src/Encoder/Xls.php on line 171"
      at /vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Worksheet/Worksheet.php line 1176
    

    That is because Worksheet::setCellValue($coordinate, $value, ?IValueBinder $binder = null) expects the first parameter $coordinate to be:
    array|CellAddress|string $coordinate Coordinate of the cell as a string, eg: 'C5'; or as an array of [$columnIndex, $row] (e.g. [3, 5]), or a CellAddress object.

    So we need to change:

    -        $sheet->setCellValue($column, $i + 2, $this->formatValue($value));
    +        $sheet->setCellValue([$column, $i + 2], $this->formatValue($value));

    This is done in 🐛 Tests are failing on 10.1 Fixed . So you need to also apply the patch from this issue (after the patch from here).

Production build 0.69.0 2024