PHPOffice / PhpSpreadsheet

A pure PHP library for reading and writing spreadsheet files
https://phpspreadsheet.readthedocs.io
MIT License
13.34k stars 3.47k forks source link

No charts are created for xls files #3784

Closed flyke closed 1 year ago

flyke commented 1 year ago

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?

Convert a .xls spreadsheet with charts to PDF: the PDF contains the same charts

What is the current behavior?

When converting a .xls spreadsheet to PDF, the PDF has no charts at all

What are the steps to reproduce?

use PhpOffice\PhpSpreadsheet\IOFactory as SpreadsheetIOFactory; use PhpOffice\PhpSpreadsheet\Writer\Pdf\Mpdf as ExcelMPDF;

  // Set a class which will render the charts.
  \PhpOffice\PhpSpreadsheet\Settings::setChartRenderer(
    \PhpOffice\PhpSpreadsheet\Chart\Renderer\MtJpGraphRenderer::class
  );
  // Load the document.
  $reader = SpreadsheetIOFactory::createReader('Xls');
  $reader->setIncludeCharts(true);
  $document = $reader->load('demo-xls-file.xls');
  // Set up the writer
  $writer = new ExcelMPDF($document);
  $writer->setIncludeCharts(true);
  $writer->save('demo-xls-file.pdf');

Screenshot of the source xls file:
![source-xls-file](https://github.com/PHPOffice/PhpSpreadsheet/assets/9461338/fa7bc24e-6ba6-4b7d-963a-79aa1bed4745)

Screenshot of the result PDF file:
![result-pdf-file](https://github.com/PHPOffice/PhpSpreadsheet/assets/9461338/fb66d707-7096-429c-8ff0-20f733e196d0)

### 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?
This is for .xls files

### Which versions of PhpSpreadsheet and PHP are affected?
- PhpSpreadsheet 1.29.0
- I'm using PHP 8.1.23
oleibman commented 1 year ago

You are unfortunately correct. There is no support for charts for xls. There is also precious little information on how to generate or read a chart in the BIFF format which xls uses. I have added a note to issue #3403 to formally document this lack of support, and will therefore close this issue now. Sorry.