From 78e8e120720c093f88b948d4ba6c0997ca055d76 Mon Sep 17 00:00:00 2001 From: Manuel Reinhard Date: Thu, 23 May 2024 13:01:28 +0200 Subject: [PATCH] Catch exception if first excel sheet does not exist --- lib/HtmlPhpExcel/HtmlPhpExcel.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/HtmlPhpExcel/HtmlPhpExcel.php b/lib/HtmlPhpExcel/HtmlPhpExcel.php index 311d965..4535bf0 100644 --- a/lib/HtmlPhpExcel/HtmlPhpExcel.php +++ b/lib/HtmlPhpExcel/HtmlPhpExcel.php @@ -139,8 +139,10 @@ private function parseHtml(): void private function createExcel(): void { - // Remove 1st sheet created automatically with new excel - $this->excel->removeSheet(1); + // Remove 1st sheet, which might be created automatically with new excel + try { + $this->excel->removeSheet(1); + } catch (\Exception) {} // Loop over all tables in document foreach($this->document->getTables() as $table) {