From 5a2830c4991823db2b2e1ce94a5fea31b4dbb734 Mon Sep 17 00:00:00 2001 From: Mark Baker Date: Fri, 21 Jan 2011 10:47:20 +0000 Subject: [PATCH] Bugfix: Work item 15129 - Worksheet fromArray() only working with 2-D arrays git-svn-id: https://phpexcel.svn.codeplex.com/svn/trunk@67182 2327b42d-5241-43d6-9e2a-de5ac946f064 --- Classes/PHPExcel/Worksheet.php | 5 +++++ changelog.txt | 1 + 2 files changed, 6 insertions(+) diff --git a/Classes/PHPExcel/Worksheet.php b/Classes/PHPExcel/Worksheet.php index b1397502..4e3d2b76 100644 --- a/Classes/PHPExcel/Worksheet.php +++ b/Classes/PHPExcel/Worksheet.php @@ -2105,6 +2105,11 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable */ public function fromArray($source = null, $nullValue = null, $startCell = 'A1', $strictNullComparison = false) { if (is_array($source)) { + // Convert a 1-D array to 2-D (for ease of looping) + if (!is_array(end($source))) { + $source = array($source); + } + // start coordinate list ($startColumn, $startRow) = PHPExcel_Cell::coordinateFromString($startCell); diff --git a/changelog.txt b/changelog.txt index fb3cfc8e..e5eae9ec 100644 --- a/changelog.txt +++ b/changelog.txt @@ -45,6 +45,7 @@ Fixed in SVN: - Bugfix: (MBaker) Minor patchfix for Excel2003XML Reader when XML is defined with a charset attribute - Bugfix: (MBaker) Work item 15089 - PHPExcel_Worksheet->toArray() index problem - Bugfix: (MBaker) Work item 15094 - Merge cells 'un-merge' when using an existing spreadsheet +- Bugfix: (MBaker) Work item 15129 - Worksheet fromArray() only working with 2-D arrays - General: (MBaker) Improved performance (speed), for building the Shared Strings table in the Excel2007 Writer.