From 1df5f97a5b2c9ca65ea3aca065394bcc1a42349d Mon Sep 17 00:00:00 2001 From: Alexander Kurilo Date: Mon, 17 Oct 2016 00:56:18 +0300 Subject: [PATCH] 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. --- src/PhpSpreadsheet/Writer/Xls.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/PhpSpreadsheet/Writer/Xls.php b/src/PhpSpreadsheet/Writer/Xls.php index 1ca8921188..d60a415cb7 100644 --- a/src/PhpSpreadsheet/Writer/Xls.php +++ b/src/PhpSpreadsheet/Writer/Xls.php @@ -454,6 +454,9 @@ private function buildWorkbookEscher() // the BSE's (all the images) foreach ($this->spreadsheet->getAllsheets() as $sheet) { 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) { $filename = $drawing->getPath();