PHPOffice / PhpSpreadsheet

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

Unable to access External Workbook #4075

Open CosminCotulbea opened 5 months ago

CosminCotulbea commented 5 months ago

Hello,

I have this issues where i get this error "Unable to access External Workbook". I'm trying to convert an xlsx file into a pdf or html but on writer save i get this error.

I tryed in two ways: 1)

$xml = new PhpOffice\PhpSpreadsheet\Reader\Xlsx(); $xml->setIncludeCharts(true); $spreadsheet = $xml->load($localTempFile); $writer = new \PhpOffice\PhpSpreadsheet\Writer\Html($spreadsheet); $writer->setIncludeCharts(true); $writer->writeAllSheets(); $writer->save('throwing_excel.html');

2) $reader = \PhpOffice\PhpSpreadsheet\IOFactory::createReader('Xlsx'); $reader->setIncludeCharts(true); $document = $reader->load($localTempFile); $writer = new Dompdf($document); $writer->setIncludeCharts(true); $writer->save('throwing_excel.pdf');

The error is thrown when I call the save method on the last row.

CosminCotulbea commented 5 months ago

I forget to tell that I have some charts and use this in appServiceProvider

\PhpOffice\PhpSpreadsheet\Settings::setChartRenderer( \PhpOffice\PhpSpreadsheet\Chart\Renderer\MtJpGraphRenderer::class );

If i remove this part from provider everything work but the charts will not appear in the generated file.

oleibman commented 5 months ago

Unable to duplicate - using your code, I have no problem saving in either Html or Dompdf including the graph. Can you upload the spreadsheet that is giving you a problem?

CosminCotulbea commented 5 months ago

with a new xlsx file only with a simple chart and some data i get an other error image

CosminCotulbea commented 5 months ago

I found that the file was corrupted but now i have a problem with that charts with data from other sheets: "Call to a member function getDataValue() on false"

If i remove that charts everything work but while i have that charts with data from other sheet throw this error on save.

image