From d4b72461755a0603368d8f10e376406170088fcf Mon Sep 17 00:00:00 2001 From: Fabio Daniele Date: Wed, 14 Oct 2015 20:05:32 +0200 Subject: [PATCH] Fix additional empty worksheet in excel creation When instancing the ExcelWriter class, if the first sheet is given a custom name the class adds an empty 'Worksheet'. This is due to the creation of a default sheet operated by the construct of the PHPExcel class. --- src/Writer/ExcelWriter.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/Writer/ExcelWriter.php b/src/Writer/ExcelWriter.php index f1321a2e..c78ec6c7 100644 --- a/src/Writer/ExcelWriter.php +++ b/src/Writer/ExcelWriter.php @@ -67,6 +67,10 @@ public function prepare() $this->excel = $reader->load($this->filename); } else { $this->excel = new PHPExcel(); + if(null !== $this->sheet && !$this->excel->sheetNameExists($this->sheet)) + { + $this->excel->removeSheetByIndex(0); + } } if (null !== $this->sheet) {