-
Notifications
You must be signed in to change notification settings - Fork 3.6k
Closed
Description
This is:
- [x] 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?
A spreadsheet should be saved and opened multiple times, even if it contains images.
What is the current behavior?
When opening and saving the file again, after it was saved, the following PHP error is generated:
Fatal error: Uncaught PhpOffice\PhpSpreadsheet\Writer\Exception:
File zip://test-out.xlsx#xl/media/image11.png does not exist in PhpOffice/PhpSpreadsheet/Writer/Xlsx/ContentTypes.php:203
Stack trace:
#0 PhpOffice/PhpSpreadsheet/Writer/Xlsx/ContentTypes.php(129): PhpOffice\PhpSpreadsheet\Writer\Xlsx\ContentTypes->getImageMimeType('zip://test-ou...')
#1 PhpOffice/PhpSpreadsheet/Writer/Xlsx.php(223): PhpOffice\PhpSpreadsheet\Writer\Xlsx\ContentTypes->writeContentTypes(Object(PhpOffice\PhpSpreadsheet\Spreadsheet), false)
#2 test.php(119): PhpOffice\PhpSpreadsheet\Writer\Xlsx->save('test-out.xlsx')
#3 {main} thrown in PhpOffice/PhpSpreadsheet/Writer/Xlsx/ContentTypes.php on line 203
What are the steps to reproduce?
Start a new document with Excel 2016 insert a small PNG image and save the document.
Upload it to webserver.
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 = IOFactory::load('test-in.xls');
$writer = IOFactory::createWriter($spreadsheet, 'Xlsx');
$writer->save('test-out.xlsx');
unset($spreadsheet, $writer); // Or a page reload
$spreadsheet = IOFactory::load('test-out.xls');
// add code that show the issue here...
$writer = IOFactory::createWriter($spreadsheet, 'Xlsx');
$writer->save('test-out.xlsx');Which versions of PhpSpreadsheet and PHP are affected?
Just downloaded the lastest version here.
PHP version 7.0.23
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels