Description
This is:
- a bug report
What is the expected behavior?
PhpSpreadsheet sould not fail loading and writing this file
What is the current behavior?
PhpSpreasheet throws a TypeError when writing the file
What are the steps to reproduce?
(for now I do not have a reproduction without an excel file)
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
use PhpOffice\PhpSpreadsheet\Reader\IReader;
use PhpOffice\PhpSpreadsheet\Reader\Xlsx as XlsxReader;
use PhpOffice\PhpSpreadsheet\Writer\IWriter;
use PhpOffice\PhpSpreadsheet\Writer\Xlsx as XlsxWriter;
require_once "vendor/autoload.php";
$reader = new XlsxReader();
$spreadsheet = $reader->load("example_plot_grouping_type_null.xlsx", IReader::LOAD_WITH_CHARTS);
$writer = new XlsxWriter($spreadsheet);
$writer->save("example_updated.xlsx", IWriter::SAVE_WITH_CHARTS);
Here is the file: example_plot_grouping_type_null.xlsx
Note that I was able to generate such a file from scratch on Google Sheet: sheet_with_combo_chart.xlsx
- Create a new sheet
- Create 2 columns of data
- Create a chart on those columns
- In the settings of the chart chose combo chart
- Remove X axis
- Add missing Y axis
What features do you think are causing the issue
- Reader
- Writer
- Styles
- Data Validations
- Formula Calculations
- Charts
- AutoFilter
- Form Elements
Does an issue affect all spreadsheet file formats? If not, which formats are affected?
I'm not sure
Which versions of PhpSpreadsheet and PHP are affected?
Latest version of PhpSpreadsheet (2.0.0) with PHP 8.1.2-1ubuntu2.14 (but should be any supported php version.
Analysis
This most likely is caused because the following call can return null
:
And because the parameter is passed by reference:
Thank you for this awesome library!