From 8fd1825d39357afa2c99992ad775a1f7318265ef Mon Sep 17 00:00:00 2001 From: simivar Date: Fri, 14 Apr 2017 13:45:53 +0200 Subject: [PATCH] Throw exception in XLS with columns or rows overflow (#138) This is a hard limit of the BIFF format that cannot be worked around, so it is best to throw exceptions than silently discard data or generate corrupted files. --- src/PhpSpreadsheet/Writer/Xls/Worksheet.php | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/PhpSpreadsheet/Writer/Xls/Worksheet.php b/src/PhpSpreadsheet/Writer/Xls/Worksheet.php index f4a36b4a..006d1b22 100644 --- a/src/PhpSpreadsheet/Writer/Xls/Worksheet.php +++ b/src/PhpSpreadsheet/Writer/Xls/Worksheet.php @@ -287,8 +287,6 @@ class Worksheet extends BIFFwriter { $phpSheet = $this->phpSheet; - $num_sheets = $phpSheet->getParent()->getSheetCount(); - // Write BOF record $this->storeBof(0x0010); @@ -405,9 +403,9 @@ class Worksheet extends BIFFwriter $row = $cell->getRow() - 1; $column = \PhpOffice\PhpSpreadsheet\Cell::columnIndexFromString($cell->getColumn()) - 1; - // Don't break Excel! + // Don't break Excel break the code! if ($row > 65535 || $column > 255) { - break; + throw new \PhpOffice\PhpSpreadsheet\Writer\Exception('Rows or columns overflow! Excel5 has limit to 65535 rows and 255 columns. Use XLSX instead.'); } // Write cell value