diff --git a/Classes/PHPExcel/Worksheet.php b/Classes/PHPExcel/Worksheet.php index 1f998e19..8840c682 100644 --- a/Classes/PHPExcel/Worksheet.php +++ b/Classes/PHPExcel/Worksheet.php @@ -2082,7 +2082,7 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable /** * Set right-to-left * - * @param boolean $value Right-to-left true/false + * @param boolean $value Right-to-left true/false * @return PHPExcel_Worksheet */ public function setRightToLeft($value = false) { @@ -2093,23 +2093,32 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable /** * Fill worksheet from values in array * - * @param array $source Source array - * @param mixed $nullValue Value in source array that stands for blank cell + * @param array $source Source array + * @param mixed $nullValue Value in source array that stands for blank cell + * @param string $startCell Insert array starting from this cell address as the top left coordinate + * @param boolean $strictNullComparison Apply strict comparison when testing for null values in the array * @throws Exception * @return PHPExcel_Worksheet */ - public function fromArray($source = null, $nullValue = null, $pCell = 'A1') { + public function fromArray($source = null, $nullValue = null, $startCell = 'A1', $strictNullComparison = false) { if (is_array($source)) { // start coordinate - list ($startColumn, $startRow) = PHPExcel_Cell::coordinateFromString($pCell); + list ($startColumn, $startRow) = PHPExcel_Cell::coordinateFromString($startCell); // Loop through $source foreach ($source as $rowData) { $currentColumn = $startColumn; foreach($rowData as $cellValue) { - if ($cellValue != $nullValue) { - // Set cell value - $this->getCell($currentColumn . $startRow)->setValue($cellValue); + if ($strictNullComparison) { + if ($cellValue !== $nullValue) { + // Set cell value + $this->getCell($currentColumn . $startRow)->setValue($cellValue); + } + } else { + if ($cellValue != $nullValue) { + // Set cell value + $this->getCell($currentColumn . $startRow)->setValue($cellValue); + } } ++$currentColumn; } diff --git a/changelog.txt b/changelog.txt index 384ce70e..0894690e 100644 --- a/changelog.txt +++ b/changelog.txt @@ -34,6 +34,7 @@ Fixed in SVN: - Feature: (MBaker) Configure PDF Writer margins based on Excel Worksheet Margin Settings value - Feature: (MBaker) Added Contiguous flag for the CSV Reader, when working with Read Filters - Feature: (MBaker) Added getFormattedValue() method for cell object +- Feature: (MBaker) Added strictNullComparison argument to the worksheet fromArray() method - Bugfix: (MB) Work item 14143 - NA() doesn't propagate in matrix calc - quick fix in JAMA/Matrix.php - Bugfix: (Progi1984) Work item 7895 - Excel5 : Formula : String constant containing double quotation mark - Bugfix: (Progi1984) Work item 7895 - Excel5 : Formula : Percent