mirror of
https://github.com/retailcrm/PHPExcel.git
synced 2024-11-22 21:36:05 +03:00
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:
parent
b25ced63cc
commit
6c9a41879b
@ -2095,22 +2095,31 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
|
|||||||
*
|
*
|
||||||
* @param array $source Source array
|
* @param array $source Source array
|
||||||
* @param mixed $nullValue Value in source array that stands for blank cell
|
* @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
|
* @throws Exception
|
||||||
* @return PHPExcel_Worksheet
|
* @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)) {
|
if (is_array($source)) {
|
||||||
// start coordinate
|
// start coordinate
|
||||||
list ($startColumn, $startRow) = PHPExcel_Cell::coordinateFromString($pCell);
|
list ($startColumn, $startRow) = PHPExcel_Cell::coordinateFromString($startCell);
|
||||||
|
|
||||||
// Loop through $source
|
// Loop through $source
|
||||||
foreach ($source as $rowData) {
|
foreach ($source as $rowData) {
|
||||||
$currentColumn = $startColumn;
|
$currentColumn = $startColumn;
|
||||||
foreach($rowData as $cellValue) {
|
foreach($rowData as $cellValue) {
|
||||||
|
if ($strictNullComparison) {
|
||||||
|
if ($cellValue !== $nullValue) {
|
||||||
|
// Set cell value
|
||||||
|
$this->getCell($currentColumn . $startRow)->setValue($cellValue);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
if ($cellValue != $nullValue) {
|
if ($cellValue != $nullValue) {
|
||||||
// Set cell value
|
// Set cell value
|
||||||
$this->getCell($currentColumn . $startRow)->setValue($cellValue);
|
$this->getCell($currentColumn . $startRow)->setValue($cellValue);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
++$currentColumn;
|
++$currentColumn;
|
||||||
}
|
}
|
||||||
++$startRow;
|
++$startRow;
|
||||||
|
@ -34,6 +34,7 @@ Fixed in SVN:
|
|||||||
- Feature: (MBaker) Configure PDF Writer margins based on Excel Worksheet Margin Settings value
|
- 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 Contiguous flag for the CSV Reader, when working with Read Filters
|
||||||
- Feature: (MBaker) Added getFormattedValue() method for cell object
|
- 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: (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 : String constant containing double quotation mark
|
||||||
- Bugfix: (Progi1984) Work item 7895 - Excel5 : Formula : Percent
|
- Bugfix: (Progi1984) Work item 7895 - Excel5 : Formula : Percent
|
||||||
|
Loading…
Reference in New Issue
Block a user