From f93402fd5485a0fae48b2e66c6bfea4910bea898 Mon Sep 17 00:00:00 2001 From: DMGPage Date: Tue, 14 Jul 2015 16:16:15 +0300 Subject: [PATCH] Update SpreadsheetReader_XLS.php Fix for "Undefined index: cells" error when document has empty sheets. --- SpreadsheetReader_XLS.php | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/SpreadsheetReader_XLS.php b/SpreadsheetReader_XLS.php index 2031f07..8397fbb 100644 --- a/SpreadsheetReader_XLS.php +++ b/SpreadsheetReader_XLS.php @@ -125,15 +125,16 @@ public function ChangeSheet($Index) { $this -> rewind(); $this -> CurrentSheet = $this -> SheetIndexes[$Index]; + $currentSheet = $this -> Handle -> sheets[$this -> CurrentSheet]; - $this -> ColumnCount = $this -> Handle -> sheets[$this -> CurrentSheet]['numCols']; - $this -> RowCount = $this -> Handle -> sheets[$this -> CurrentSheet]['numRows']; + $this -> ColumnCount = $currentSheet['numCols']; + $this -> RowCount = $currentSheet['numRows']; // For the case when Spreadsheet_Excel_Reader doesn't have the row count set correctly. - if (!$this -> RowCount && count($this -> Handle -> sheets[$this -> CurrentSheet]['cells'])) + if (!$this -> RowCount && isset($currentSheet['cells']) && count($currentSheet['cells'])) { - end($this -> Handle -> sheets[$this -> CurrentSheet]['cells']); - $this -> RowCount = (int)key($this -> Handle -> sheets[$this -> CurrentSheet]['cells']); + end($currentSheet['cells']); + $this -> RowCount = (int)key($currentSheet['cells']); } if ($this -> ColumnCount) @@ -263,4 +264,4 @@ public function count() return $this -> RowCount; } } -?> \ No newline at end of file +?>