Feature: Added strictNullComparison argument to the worksheet fromArray() method

git-svn-id: https://phpexcel.svn.codeplex.com/svn/trunk@64270 2327b42d-5241-43d6-9e2a-de5ac946f064
This commit is contained in:
Mark Baker 2010-11-24 15:28:15 +00:00
parent b25ced63cc
commit 6c9a41879b
2 changed files with 18 additions and 8 deletions

View File

@ -2095,22 +2095,31 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
*
* @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 ($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;
}
++$startRow;

View File

@ -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