Require GD for saving images in xls

GD is implicitly required for saving images anyway, this exception when
it's not loaded simply gives more information on what to do if the
execution flow reaches a places that depends on a function from GD.
This commit is contained in:
Alexander Kurilo 2016-10-17 00:56:18 +03:00 committed by Adrien Crivelli
parent 408da0c17a
commit 1df5f97a5b
1 changed files with 3 additions and 0 deletions

View File

@ -454,6 +454,9 @@ class Xls extends BaseWriter implements IWriter
// the BSE's (all the images) // the BSE's (all the images)
foreach ($this->spreadsheet->getAllsheets() as $sheet) { foreach ($this->spreadsheet->getAllsheets() as $sheet) {
foreach ($sheet->getDrawingCollection() as $drawing) { foreach ($sheet->getDrawingCollection() as $drawing) {
if (!extension_loaded('gd')) {
throw new \RuntimeException('Saving images in xls requires gd extension');
}
if ($drawing instanceof \PhpOffice\PhpSpreadsheet\Worksheet\Drawing) { if ($drawing instanceof \PhpOffice\PhpSpreadsheet\Worksheet\Drawing) {
$filename = $drawing->getPath(); $filename = $drawing->getPath();